mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-23 17:20:24 +08:00
parent
67db40ed4f
commit
2d4c29ea7c
@ -19,9 +19,7 @@ var (
|
|||||||
// WithTimeout is an alias of internal.WithTimeout.
|
// WithTimeout is an alias of internal.WithTimeout.
|
||||||
WithTimeout = internal.WithTimeout
|
WithTimeout = internal.WithTimeout
|
||||||
// WithRetry is an alias of internal.WithRetry.
|
// WithRetry is an alias of internal.WithRetry.
|
||||||
// TODO: enable it in v1.2.4
|
WithRetry = internal.WithRetry
|
||||||
// WithRetry = internal.WithRetry
|
|
||||||
|
|
||||||
// WithTransportCredentials return a func to make the gRPC calls secured with given credentials.
|
// WithTransportCredentials return a func to make the gRPC calls secured with given credentials.
|
||||||
WithTransportCredentials = internal.WithTransportCredentials
|
WithTransportCredentials = internal.WithTransportCredentials
|
||||||
// WithUnaryClientInterceptor is an alias of internal.WithUnaryClientInterceptor.
|
// WithUnaryClientInterceptor is an alias of internal.WithUnaryClientInterceptor.
|
||||||
@ -65,10 +63,9 @@ func NewClient(c RpcClientConf, options ...ClientOption) (Client, error) {
|
|||||||
if c.Timeout > 0 {
|
if c.Timeout > 0 {
|
||||||
opts = append(opts, WithTimeout(time.Duration(c.Timeout)*time.Millisecond))
|
opts = append(opts, WithTimeout(time.Duration(c.Timeout)*time.Millisecond))
|
||||||
}
|
}
|
||||||
// TODO: enable it in v1.2.4
|
if c.Retry {
|
||||||
// if c.Retry {
|
opts = append(opts, WithRetry())
|
||||||
// opts = append(opts, WithRetry())
|
}
|
||||||
// }
|
|
||||||
opts = append(opts, options...)
|
opts = append(opts, options...)
|
||||||
|
|
||||||
var target string
|
var target string
|
||||||
|
@ -96,21 +96,20 @@ func TestDepositServer_Deposit(t *testing.T) {
|
|||||||
return invoker(ctx, method, req, reply, cc, opts...)
|
return invoker(ctx, method, req, reply, cc, opts...)
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
// TODO: enable it in v1.2.4
|
retryClient := MustNewClient(
|
||||||
// retryClient := MustNewClient(
|
RpcClientConf{
|
||||||
// RpcClientConf{
|
Endpoints: []string{"foo"},
|
||||||
// Endpoints: []string{"foo"},
|
App: "foo",
|
||||||
// App: "foo",
|
Token: "bar",
|
||||||
// Token: "bar",
|
Timeout: 1000,
|
||||||
// Timeout: 1000,
|
Retry: true,
|
||||||
// Retry: true,
|
},
|
||||||
// },
|
WithDialOption(grpc.WithContextDialer(dialer())),
|
||||||
// WithDialOption(grpc.WithContextDialer(dialer())),
|
WithUnaryClientInterceptor(func(ctx context.Context, method string, req, reply interface{},
|
||||||
// WithUnaryClientInterceptor(func(ctx context.Context, method string, req, reply interface{},
|
cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
|
||||||
// cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
|
return invoker(ctx, method, req, reply, cc, opts...)
|
||||||
// return invoker(ctx, method, req, reply, cc, opts...)
|
}),
|
||||||
// }),
|
)
|
||||||
// )
|
|
||||||
tarConfClient := MustNewClient(
|
tarConfClient := MustNewClient(
|
||||||
RpcClientConf{
|
RpcClientConf{
|
||||||
Target: "foo",
|
Target: "foo",
|
||||||
@ -135,8 +134,7 @@ func TestDepositServer_Deposit(t *testing.T) {
|
|||||||
clients := []Client{
|
clients := []Client{
|
||||||
directClient,
|
directClient,
|
||||||
nonBlockClient,
|
nonBlockClient,
|
||||||
// TODO: enable it in v1.2.4
|
retryClient,
|
||||||
// retryClient,
|
|
||||||
tarConfClient,
|
tarConfClient,
|
||||||
targetClient,
|
targetClient,
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,7 @@ type (
|
|||||||
// setting 0 means no timeout
|
// setting 0 means no timeout
|
||||||
Timeout int64 `json:",default=2000"`
|
Timeout int64 `json:",default=2000"`
|
||||||
CpuThreshold int64 `json:",default=900,range=[0:1000]"`
|
CpuThreshold int64 `json:",default=900,range=[0:1000]"`
|
||||||
// TODO: enable it in v1.2.4
|
MaxRetries int `json:",default=0,range=[0:]"`
|
||||||
// MaxRetries int `json:",default=0,range=[0:]"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// A RpcClientConf is a rpc client config.
|
// A RpcClientConf is a rpc client config.
|
||||||
@ -30,8 +29,7 @@ type (
|
|||||||
App string `json:",optional"`
|
App string `json:",optional"`
|
||||||
Token string `json:",optional"`
|
Token string `json:",optional"`
|
||||||
NonBlock bool `json:",optional"`
|
NonBlock bool `json:",optional"`
|
||||||
// TODO: enable it in v1.2.4
|
Retry bool `json:",optional"` // grpc auto retry
|
||||||
// Retry bool `json:",optional"` // grpc auto retry
|
|
||||||
Timeout int64 `json:",default=2000"`
|
Timeout int64 `json:",default=2000"`
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -38,9 +38,10 @@ func NewServer(c RpcServerConf, register internal.RegisterFn) (*RpcServer, error
|
|||||||
|
|
||||||
var server internal.Server
|
var server internal.Server
|
||||||
metrics := stat.NewMetrics(c.ListenOn)
|
metrics := stat.NewMetrics(c.ListenOn)
|
||||||
// TODO: enable it in v1.2.4
|
serverOptions := []internal.ServerOption{
|
||||||
// serverOptions := []internal.ServerOption{internal.WithMetrics(metrics), internal.WithMaxRetries(c.MaxRetries)}
|
internal.WithMetrics(metrics),
|
||||||
serverOptions := []internal.ServerOption{internal.WithMetrics(metrics)}
|
internal.WithMaxRetries(c.MaxRetries),
|
||||||
|
}
|
||||||
|
|
||||||
if c.HasEtcd() {
|
if c.HasEtcd() {
|
||||||
server, err = internal.NewRpcPubServer(c.Etcd, c.ListenOn, serverOptions...)
|
server, err = internal.NewRpcPubServer(c.Etcd, c.ListenOn, serverOptions...)
|
||||||
|
Loading…
Reference in New Issue
Block a user