From f59bf91a67cc403ab03f6752a4947678d3879996 Mon Sep 17 00:00:00 2001 From: Denis Kirillov Date: Fri, 14 Oct 2022 13:07:47 +0300 Subject: [PATCH] [#699] neofs/tree: Add healthcheck Signed-off-by: Denis Kirillov --- cmd/s3-gw/app.go | 2 +- internal/neofs/tree.go | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/s3-gw/app.go b/cmd/s3-gw/app.go index 4ea94b12d..50f98aa2c 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 baba76e48..d99e55b74 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,