[#205] sdk/client: Support option to set dial timeout

There is a need to set dial timeout in SDK client that is used in case of
internal connection opening. Add DialTimeout option constructor to support
this feature.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-11-23 14:05:27 +03:00 committed by Alex Vanin
parent 03ac6bedb4
commit 5ee500bb43
6 changed files with 23 additions and 8 deletions

View file

@ -2,6 +2,7 @@ package client
import (
"fmt"
"time"
"github.com/nspcc-dev/neofs-api-go/pkg"
"github.com/nspcc-dev/neofs-api-go/pkg/token"
@ -35,6 +36,8 @@ type (
clientOptions struct {
addr string
dialTimeout time.Duration
grpcOpts *grpcOptions
}
@ -168,3 +171,10 @@ func WithGRPCConnection(grpcConn *grpc.ClientConn) Option {
option.grpcOpts.conn = grpcConn
})
}
// WithDialTimeout returns option to set connection timeout to the remote node.
func WithDialTimeout(dur time.Duration) Option {
return newFuncClientOption(func(option *clientOptions) {
option.dialTimeout = dur
})
}