From 1dc3b77ac792f876639438b827ebe99b1c9208e3 Mon Sep 17 00:00:00 2001 From: Dmitrii Stepanov Date: Mon, 16 Sep 2024 14:35:24 +0300 Subject: [PATCH] [#270] pool: Replace deprecated DialContext `Healthcheck` request performed after client creation, so no extra RPC required. Signed-off-by: Dmitrii Stepanov --- pool/tree/client.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pool/tree/client.go b/pool/tree/client.go index 476026f..c6562c7 100644 --- a/pool/tree/client.go +++ b/pool/tree/client.go @@ -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