|
@@ -67,6 +67,8 @@ type Client struct {
|
|
|
Password string
|
|
Password string
|
|
|
// tokenCred is an instance of WithPerRPCCredentials()'s argument
|
|
// tokenCred is an instance of WithPerRPCCredentials()'s argument
|
|
|
tokenCred *authTokenCredential
|
|
tokenCred *authTokenCredential
|
|
|
|
|
+
|
|
|
|
|
+ callOpts []grpc.CallOption
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// New creates a new etcdv3 client from a given configuration.
|
|
// New creates a new etcdv3 client from a given configuration.
|
|
@@ -386,11 +388,29 @@ func newClient(cfg *Config) (*Client, error) {
|
|
|
ctx: ctx,
|
|
ctx: ctx,
|
|
|
cancel: cancel,
|
|
cancel: cancel,
|
|
|
mu: new(sync.Mutex),
|
|
mu: new(sync.Mutex),
|
|
|
|
|
+ callOpts: defaultCallOpts,
|
|
|
}
|
|
}
|
|
|
if cfg.Username != "" && cfg.Password != "" {
|
|
if cfg.Username != "" && cfg.Password != "" {
|
|
|
client.Username = cfg.Username
|
|
client.Username = cfg.Username
|
|
|
client.Password = cfg.Password
|
|
client.Password = cfg.Password
|
|
|
}
|
|
}
|
|
|
|
|
+ if cfg.MaxCallSendMsgSize > 0 || cfg.MaxCallRecvMsgSize > 0 {
|
|
|
|
|
+ if cfg.MaxCallRecvMsgSize > 0 && cfg.MaxCallSendMsgSize > cfg.MaxCallRecvMsgSize {
|
|
|
|
|
+ return nil, fmt.Errorf("gRPC message recv limit (%d bytes) must be greater than send limit (%d bytes)", cfg.MaxCallRecvMsgSize, cfg.MaxCallSendMsgSize)
|
|
|
|
|
+ }
|
|
|
|
|
+ callOpts := []grpc.CallOption{
|
|
|
|
|
+ defaultFailFast,
|
|
|
|
|
+ defaultMaxCallSendMsgSize,
|
|
|
|
|
+ defaultMaxCallRecvMsgSize,
|
|
|
|
|
+ }
|
|
|
|
|
+ if cfg.MaxCallSendMsgSize > 0 {
|
|
|
|
|
+ callOpts[1] = grpc.MaxCallSendMsgSize(cfg.MaxCallSendMsgSize)
|
|
|
|
|
+ }
|
|
|
|
|
+ if cfg.MaxCallRecvMsgSize > 0 {
|
|
|
|
|
+ callOpts[2] = grpc.MaxCallRecvMsgSize(cfg.MaxCallRecvMsgSize)
|
|
|
|
|
+ }
|
|
|
|
|
+ client.callOpts = callOpts
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
client.balancer = newHealthBalancer(cfg.Endpoints, cfg.DialTimeout, func(ep string) (bool, error) {
|
|
client.balancer = newHealthBalancer(cfg.Endpoints, cfg.DialTimeout, func(ep string) (bool, error) {
|
|
|
return grpcHealthCheck(client, ep)
|
|
return grpcHealthCheck(client, ep)
|