forked from TrueCloudLab/frostfs-node
[#1115] neofs-adm: use request timeout in N3 client
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
0695ec4125
commit
a91b59fff9
1 changed files with 9 additions and 3 deletions
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue