forked from TrueCloudLab/frostfs-api-go
[#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:
parent
03ac6bedb4
commit
5ee500bb43
6 changed files with 23 additions and 8 deletions
|
@ -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
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue