Skip to content

Commit

Permalink
fix: Make custom DialOption overwrite default ones
Browse files Browse the repository at this point in the history
See also milvus-io#699

Signed-off-by: Congqi Xia <[email protected]>
  • Loading branch information
congqixia committed Apr 26, 2024
1 parent b8a1b6d commit a236ce4
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions client/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,20 +136,21 @@ func (c *Config) setIdentifier(identifier string) {

// Get parsed grpc dial options, should be called after parse was called.
func (c *Config) getDialOption() []grpc.DialOption {
options := c.DialOptions
if c.DialOptions == nil {
// Add default connection options.
options = make([]grpc.DialOption, len(DefaultGrpcOpts))
copy(options, DefaultGrpcOpts)
}

var options []grpc.DialOption
// Construct dial option.
if c.EnableTLSAuth {
options = append(options, grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{})))
} else {
options = append(options, grpc.WithTransportCredentials(insecure.NewCredentials()))
}

if c.DialOptions == nil {
// Add default connection options.
options = append(options, DefaultGrpcOpts...)
} else {
options = append(options, c.DialOptions...)
}

options = append(options,
grpc.WithChainUnaryInterceptor(grpc_retry.UnaryClientInterceptor(
grpc_retry.WithMax(6),
Expand Down

0 comments on commit a236ce4

Please sign in to comment.