[#1115] neofs-adm: use request timeout in N3 client

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2022-02-07 16:58:56 +03:00 committed by Alex Vanin
parent 0695ec4125
commit a91b59fff9

View file

@ -22,14 +22,20 @@ type clientContext struct {
func getN3Client(v *viper.Viper) (*client.Client, error) { func getN3Client(v *viper.Viper) (*client.Client, error) {
// number of opened connections // number of opened connections
// by neo-go client per one host // 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) endpoint := v.GetString(endpointFlag)
if endpoint == "" { if endpoint == "" {
return nil, errors.New("missing 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 { if err != nil {
return nil, err return nil, err
} }