From a91b59fff95bf2c5b171fef75ed735499b0111dd Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Mon, 7 Feb 2022 16:58:56 +0300 Subject: [PATCH] [#1115] neofs-adm: use request timeout in N3 client Signed-off-by: Evgenii Stratonikov --- cmd/neofs-adm/internal/modules/morph/n3client.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cmd/neofs-adm/internal/modules/morph/n3client.go b/cmd/neofs-adm/internal/modules/morph/n3client.go index 86cfde298..77e304dcc 100644 --- a/cmd/neofs-adm/internal/modules/morph/n3client.go +++ b/cmd/neofs-adm/internal/modules/morph/n3client.go @@ -22,14 +22,20 @@ type clientContext struct { func getN3Client(v *viper.Viper) (*client.Client, error) { // number of opened connections // by neo-go client per one host - const maxConnsPerHost = 10 + const ( + maxConnsPerHost = 10 + requestTimeout = time.Second * 10 + ) - ctx := context.Background() // FIXME(@fyrchik): timeout context + ctx := context.Background() endpoint := v.GetString(endpointFlag) if endpoint == "" { return nil, errors.New("missing endpoint") } - c, err := client.New(ctx, endpoint, client.Options{MaxConnsPerHost: maxConnsPerHost}) + c, err := client.New(ctx, endpoint, client.Options{ + MaxConnsPerHost: maxConnsPerHost, + RequestTimeout: requestTimeout, + }) if err != nil { return nil, err }