forked from TrueCloudLab/frostfs-http-gw
connections: make use of keepalive options
This commit is contained in:
parent
afbb9d51f1
commit
f99f9e88a7
2 changed files with 16 additions and 1 deletions
3
app.go
3
app.go
|
@ -114,6 +114,9 @@ func newApp(ctx context.Context, opt ...Option) App {
|
||||||
NodeRequestTimeout: a.cfg.GetDuration(cfgReqTimeout),
|
NodeRequestTimeout: a.cfg.GetDuration(cfgReqTimeout),
|
||||||
ClientRebalanceInterval: a.cfg.GetDuration(cfgRebalance),
|
ClientRebalanceInterval: a.cfg.GetDuration(cfgRebalance),
|
||||||
SessionExpirationEpoch: math.MaxUint64,
|
SessionExpirationEpoch: math.MaxUint64,
|
||||||
|
KeepaliveTime: a.cfg.GetDuration(cfgKeepaliveTime),
|
||||||
|
KeepaliveTimeout: a.cfg.GetDuration(cfgKeepaliveTimeout),
|
||||||
|
KeepalivePermitWoStream: a.cfg.GetBool(cfgKeepalivePermitWithoutStream),
|
||||||
}
|
}
|
||||||
pool, err := pb.Build(ctx, opts)
|
pool, err := pb.Build(ctx, opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -12,6 +12,7 @@ import (
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/client"
|
"github.com/nspcc-dev/neofs-api-go/pkg/client"
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/token"
|
"github.com/nspcc-dev/neofs-api-go/pkg/token"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
|
"google.golang.org/grpc/keepalive"
|
||||||
)
|
)
|
||||||
|
|
||||||
type PoolBuilderOptions struct {
|
type PoolBuilderOptions struct {
|
||||||
|
@ -19,6 +20,9 @@ type PoolBuilderOptions struct {
|
||||||
NodeConnectionTimeout time.Duration
|
NodeConnectionTimeout time.Duration
|
||||||
NodeRequestTimeout time.Duration
|
NodeRequestTimeout time.Duration
|
||||||
ClientRebalanceInterval time.Duration
|
ClientRebalanceInterval time.Duration
|
||||||
|
KeepaliveTime time.Duration
|
||||||
|
KeepaliveTimeout time.Duration
|
||||||
|
KeepalivePermitWoStream bool
|
||||||
SessionExpirationEpoch uint64
|
SessionExpirationEpoch uint64
|
||||||
weights []float64
|
weights []float64
|
||||||
connections []*grpc.ClientConn
|
connections []*grpc.ClientConn
|
||||||
|
@ -51,7 +55,15 @@ func (pb *PoolBuilder) Build(ctx context.Context, options *PoolBuilderOptions) (
|
||||||
con, err := func() (*grpc.ClientConn, error) {
|
con, err := func() (*grpc.ClientConn, error) {
|
||||||
toctx, c := context.WithTimeout(ctx, options.NodeConnectionTimeout)
|
toctx, c := context.WithTimeout(ctx, options.NodeConnectionTimeout)
|
||||||
defer c()
|
defer c()
|
||||||
return grpc.DialContext(toctx, address, grpc.WithInsecure(), grpc.WithBlock())
|
return grpc.DialContext(toctx, address,
|
||||||
|
grpc.WithInsecure(),
|
||||||
|
grpc.WithBlock(),
|
||||||
|
grpc.WithKeepaliveParams(keepalive.ClientParameters{
|
||||||
|
Time: options.KeepaliveTime,
|
||||||
|
Timeout: options.KeepaliveTimeout,
|
||||||
|
PermitWithoutStream: options.KeepalivePermitWoStream,
|
||||||
|
}),
|
||||||
|
)
|
||||||
}()
|
}()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
Loading…
Reference in a new issue