forked from TrueCloudLab/frostfs-sdk-go
[#270] pool: Replace deprecated DialContext
`Healthcheck` request performed after client creation, so no extra RPC required. Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
88c6556c37
commit
1dc3b77ac7
1 changed files with 5 additions and 5 deletions
|
@ -43,7 +43,7 @@ func (c *treeClient) dial(ctx context.Context) error {
|
|||
}
|
||||
|
||||
var err error
|
||||
if c.conn, c.service, err = dialClient(ctx, c.address, c.opts...); err != nil {
|
||||
if c.conn, c.service, err = createClient(c.address, c.opts...); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ func (c *treeClient) redialIfNecessary(ctx context.Context) (healthHasChanged bo
|
|||
defer c.mu.Unlock()
|
||||
|
||||
if c.conn == nil {
|
||||
if c.conn, c.service, err = dialClient(ctx, c.address, c.opts...); err != nil {
|
||||
if c.conn, c.service, err = createClient(c.address, c.opts...); err != nil {
|
||||
return false, err
|
||||
}
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ func (c *treeClient) redialIfNecessary(ctx context.Context) (healthHasChanged bo
|
|||
return !wasHealthy, nil
|
||||
}
|
||||
|
||||
func dialClient(ctx context.Context, addr string, clientOptions ...grpc.DialOption) (*grpc.ClientConn, grpcService.TreeServiceClient, error) {
|
||||
func createClient(addr string, clientOptions ...grpc.DialOption) (*grpc.ClientConn, grpcService.TreeServiceClient, error) {
|
||||
host, tlsEnable, err := apiClient.ParseURI(addr)
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("parse address: %w", err)
|
||||
|
@ -93,9 +93,9 @@ func dialClient(ctx context.Context, addr string, clientOptions ...grpc.DialOpti
|
|||
// the order is matter, we want client to be able to overwrite options.
|
||||
opts := append(options, clientOptions...)
|
||||
|
||||
conn, err := grpc.DialContext(ctx, host, opts...)
|
||||
conn, err := grpc.NewClient(host, opts...)
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("grpc dial node tree service: %w", err)
|
||||
return nil, nil, fmt.Errorf("grpc create node tree service: %w", err)
|
||||
}
|
||||
|
||||
return conn, grpcService.NewTreeServiceClient(conn), nil
|
||||
|
|
Loading…
Reference in a new issue