diff --git a/cmd/s3-gw/app.go b/cmd/s3-gw/app.go index 4ea94b1..50f98aa 100644 --- a/cmd/s3-gw/app.go +++ b/cmd/s3-gw/app.go @@ -121,7 +121,7 @@ func (a *App) initLayer(ctx context.Context) { a.initResolver() treeServiceEndpoint := a.cfg.GetString(cfgTreeServiceEndpoint) - treeService, err := neofs.NewTreeClient(treeServiceEndpoint, a.key) + treeService, err := neofs.NewTreeClient(ctx, treeServiceEndpoint, a.key) if err != nil { a.log.Fatal("failed to create tree service", zap.Error(err)) } diff --git a/internal/neofs/tree.go b/internal/neofs/tree.go index baba76e..d99e55b 100644 --- a/internal/neofs/tree.go +++ b/internal/neofs/tree.go @@ -91,13 +91,16 @@ const ( ) // NewTreeClient creates instance of TreeClient using provided address and create grpc connection. -func NewTreeClient(addr string, key *keys.PrivateKey) (*TreeClient, error) { +func NewTreeClient(ctx context.Context, addr string, key *keys.PrivateKey) (*TreeClient, error) { conn, err := grpc.Dial(addr, grpc.WithTransportCredentials(insecure.NewCredentials())) if err != nil { return nil, fmt.Errorf("did not connect: %v", err) } c := tree.NewTreeServiceClient(conn) + if _, err = c.Healthcheck(ctx, &tree.HealthcheckRequest{}); err != nil { + return nil, fmt.Errorf("healthcheck: %w", err) + } return &TreeClient{ key: key,