|
|
@ -35,6 +35,7 @@ type (
|
|
|
|
|
|
|
|
|
|
|
|
// A ClientOptions is a client options.
|
|
|
|
// A ClientOptions is a client options.
|
|
|
|
ClientOptions struct {
|
|
|
|
ClientOptions struct {
|
|
|
|
|
|
|
|
NonBlock bool
|
|
|
|
Timeout time.Duration
|
|
|
|
Timeout time.Duration
|
|
|
|
Secure bool
|
|
|
|
Secure bool
|
|
|
|
Retry bool
|
|
|
|
Retry bool
|
|
|
@ -75,8 +76,11 @@ func (c *client) buildDialOptions(opts ...ClientOption) []grpc.DialOption {
|
|
|
|
options = append([]grpc.DialOption(nil), grpc.WithInsecure())
|
|
|
|
options = append([]grpc.DialOption(nil), grpc.WithInsecure())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if !cliOpts.NonBlock {
|
|
|
|
|
|
|
|
options = append(options, grpc.WithBlock())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
options = append(options,
|
|
|
|
options = append(options,
|
|
|
|
grpc.WithBlock(),
|
|
|
|
|
|
|
|
WithUnaryClientInterceptors(
|
|
|
|
WithUnaryClientInterceptors(
|
|
|
|
clientinterceptors.UnaryTracingInterceptor,
|
|
|
|
clientinterceptors.UnaryTracingInterceptor,
|
|
|
|
clientinterceptors.DurationInterceptor,
|
|
|
|
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.
|
|
|
|
// WithTimeout returns a func to customize a ClientOptions with given timeout.
|
|
|
|
func WithTimeout(timeout time.Duration) ClientOption {
|
|
|
|
func WithTimeout(timeout time.Duration) ClientOption {
|
|
|
|
return func(options *ClientOptions) {
|
|
|
|
return func(options *ClientOptions) {
|
|
|
|