|
|
@ -109,19 +109,26 @@ func WithLogger(log log.Logger) ClientOption { |
|
|
|
return func(o *clientOptions) {} |
|
|
|
return func(o *clientOptions) {} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func WithPrintDiscoveryDebugLog(p bool) ClientOption { |
|
|
|
|
|
|
|
return func(o *clientOptions) { |
|
|
|
|
|
|
|
o.printDiscoveryDebugLog = p |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// clientOptions is gRPC Client
|
|
|
|
// clientOptions is gRPC Client
|
|
|
|
type clientOptions struct { |
|
|
|
type clientOptions struct { |
|
|
|
endpoint string |
|
|
|
endpoint string |
|
|
|
subsetSize int |
|
|
|
subsetSize int |
|
|
|
tlsConf *tls.Config |
|
|
|
tlsConf *tls.Config |
|
|
|
timeout time.Duration |
|
|
|
timeout time.Duration |
|
|
|
discovery registry.Discovery |
|
|
|
discovery registry.Discovery |
|
|
|
middleware []middleware.Middleware |
|
|
|
middleware []middleware.Middleware |
|
|
|
ints []grpc.UnaryClientInterceptor |
|
|
|
ints []grpc.UnaryClientInterceptor |
|
|
|
streamInts []grpc.StreamClientInterceptor |
|
|
|
streamInts []grpc.StreamClientInterceptor |
|
|
|
grpcOpts []grpc.DialOption |
|
|
|
grpcOpts []grpc.DialOption |
|
|
|
balancerName string |
|
|
|
balancerName string |
|
|
|
filters []selector.NodeFilter |
|
|
|
filters []selector.NodeFilter |
|
|
|
|
|
|
|
printDiscoveryDebugLog bool |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Dial returns a GRPC connection.
|
|
|
|
// Dial returns a GRPC connection.
|
|
|
@ -136,9 +143,10 @@ func DialInsecure(ctx context.Context, opts ...ClientOption) (*grpc.ClientConn, |
|
|
|
|
|
|
|
|
|
|
|
func dial(ctx context.Context, insecure bool, opts ...ClientOption) (*grpc.ClientConn, error) { |
|
|
|
func dial(ctx context.Context, insecure bool, opts ...ClientOption) (*grpc.ClientConn, error) { |
|
|
|
options := clientOptions{ |
|
|
|
options := clientOptions{ |
|
|
|
timeout: 2000 * time.Millisecond, |
|
|
|
timeout: 2000 * time.Millisecond, |
|
|
|
balancerName: balancerName, |
|
|
|
balancerName: balancerName, |
|
|
|
subsetSize: 25, |
|
|
|
subsetSize: 25, |
|
|
|
|
|
|
|
printDiscoveryDebugLog: true, |
|
|
|
} |
|
|
|
} |
|
|
|
for _, o := range opts { |
|
|
|
for _, o := range opts { |
|
|
|
o(&options) |
|
|
|
o(&options) |
|
|
@ -169,6 +177,7 @@ func dial(ctx context.Context, insecure bool, opts ...ClientOption) (*grpc.Clien |
|
|
|
options.discovery, |
|
|
|
options.discovery, |
|
|
|
discovery.WithInsecure(insecure), |
|
|
|
discovery.WithInsecure(insecure), |
|
|
|
discovery.WithSubset(options.subsetSize), |
|
|
|
discovery.WithSubset(options.subsetSize), |
|
|
|
|
|
|
|
discovery.PrintDebugLog(options.printDiscoveryDebugLog), |
|
|
|
))) |
|
|
|
))) |
|
|
|
} |
|
|
|
} |
|
|
|
if insecure { |
|
|
|
if insecure { |
|
|
|