|
|
|
@ -35,6 +35,7 @@ type (
|
|
|
|
|
|
|
|
|
|
// A ClientOptions is a client options.
|
|
|
|
|
ClientOptions struct {
|
|
|
|
|
NonBlock bool
|
|
|
|
|
Timeout time.Duration
|
|
|
|
|
Secure bool
|
|
|
|
|
Retry bool
|
|
|
|
@ -75,8 +76,11 @@ func (c *client) buildDialOptions(opts ...ClientOption) []grpc.DialOption {
|
|
|
|
|
options = append([]grpc.DialOption(nil), grpc.WithInsecure())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !cliOpts.NonBlock {
|
|
|
|
|
options = append(options, grpc.WithBlock())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
options = append(options,
|
|
|
|
|
grpc.WithBlock(),
|
|
|
|
|
WithUnaryClientInterceptors(
|
|
|
|
|
clientinterceptors.UnaryTracingInterceptor,
|
|
|
|
|
clientinterceptors.DurationInterceptor,
|
|
|
|
@ -122,6 +126,13 @@ func WithDialOption(opt grpc.DialOption) ClientOption {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// WithNonBlock sets the dialing to be nonblock.
|
|
|
|
|
func WithNonBlock() ClientOption {
|
|
|
|
|
return func(options *ClientOptions) {
|
|
|
|
|
options.NonBlock = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// WithTimeout returns a func to customize a ClientOptions with given timeout.
|
|
|
|
|
func WithTimeout(timeout time.Duration) ClientOption {
|
|
|
|
|
return func(options *ClientOptions) {
|
|
|
|
|