[#1422] node: Use dialer source for SDK cache
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
74db735265
commit
6c96cc2af6
4 changed files with 22 additions and 12 deletions
|
@ -773,6 +773,7 @@ func initShared(appCfg *config.Config, key *keys.PrivateKey, netState *networkSt
|
||||||
Key: &key.PrivateKey,
|
Key: &key.PrivateKey,
|
||||||
AllowExternal: apiclientconfig.AllowExternal(appCfg),
|
AllowExternal: apiclientconfig.AllowExternal(appCfg),
|
||||||
ReconnectTimeout: apiclientconfig.ReconnectTimeout(appCfg),
|
ReconnectTimeout: apiclientconfig.ReconnectTimeout(appCfg),
|
||||||
|
DialerSource: ds,
|
||||||
}
|
}
|
||||||
|
|
||||||
return shared{
|
return shared{
|
||||||
|
|
|
@ -13,6 +13,10 @@ type Dialer interface {
|
||||||
DialContext(ctx context.Context, network, address string) (net.Conn, error)
|
DialContext(ctx context.Context, network, address string) (net.Conn, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func DialContextTCP(ctx context.Context, address string, d Dialer) (net.Conn, error) {
|
||||||
|
return d.DialContext(ctx, "tcp", address)
|
||||||
|
}
|
||||||
|
|
||||||
func newDefaulDialer() net.Dialer {
|
func newDefaulDialer() net.Dialer {
|
||||||
// From `grpc.WithContextDialer` comment:
|
// From `grpc.WithContextDialer` comment:
|
||||||
//
|
//
|
||||||
|
@ -28,7 +32,7 @@ func newDefaulDialer() net.Dialer {
|
||||||
KeepAlive: time.Duration(-1),
|
KeepAlive: time.Duration(-1),
|
||||||
Control: func(_, _ string, c syscall.RawConn) error {
|
Control: func(_, _ string, c syscall.RawConn) error {
|
||||||
return c.Control(func(fd uintptr) {
|
return c.Control(func(fd uintptr) {
|
||||||
unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_KEEPALIVE, 1)
|
_ = unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_KEEPALIVE, 1)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
2
pkg/network/cache/client.go
vendored
2
pkg/network/cache/client.go
vendored
|
@ -5,6 +5,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/net"
|
||||||
clientcore "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/client"
|
clientcore "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/client"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
)
|
)
|
||||||
|
@ -25,6 +26,7 @@ type (
|
||||||
Key *ecdsa.PrivateKey
|
Key *ecdsa.PrivateKey
|
||||||
ResponseCallback func(client.ResponseMetaInfo) error
|
ResponseCallback func(client.ResponseMetaInfo) error
|
||||||
AllowExternal bool
|
AllowExternal bool
|
||||||
|
DialerSource *net.DialerSource
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
25
pkg/network/cache/multi.go
vendored
25
pkg/network/cache/multi.go
vendored
|
@ -60,18 +60,21 @@ func (x *multiClient) createForAddress(ctx context.Context, addr network.Address
|
||||||
prmInit.Key = *x.opts.Key
|
prmInit.Key = *x.opts.Key
|
||||||
}
|
}
|
||||||
|
|
||||||
|
grpcOpts := []grpc.DialOption{
|
||||||
|
grpc.WithChainUnaryInterceptor(
|
||||||
|
metrics.NewUnaryClientInterceptor(),
|
||||||
|
tracing.NewUnaryClientInteceptor(),
|
||||||
|
),
|
||||||
|
grpc.WithChainStreamInterceptor(
|
||||||
|
metrics.NewStreamClientInterceptor(),
|
||||||
|
tracing.NewStreamClientInterceptor(),
|
||||||
|
),
|
||||||
|
grpc.WithContextDialer(x.opts.DialerSource.GrpcContextDialer()),
|
||||||
|
}
|
||||||
|
|
||||||
prmDial := client.PrmDial{
|
prmDial := client.PrmDial{
|
||||||
Endpoint: addr.URIAddr(),
|
Endpoint: addr.URIAddr(),
|
||||||
GRPCDialOptions: []grpc.DialOption{
|
GRPCDialOptions: grpcOpts,
|
||||||
grpc.WithChainUnaryInterceptor(
|
|
||||||
metrics.NewUnaryClientInterceptor(),
|
|
||||||
tracing.NewUnaryClientInteceptor(),
|
|
||||||
),
|
|
||||||
grpc.WithChainStreamInterceptor(
|
|
||||||
metrics.NewStreamClientInterceptor(),
|
|
||||||
tracing.NewStreamClientInterceptor(),
|
|
||||||
),
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
if x.opts.DialTimeout > 0 {
|
if x.opts.DialTimeout > 0 {
|
||||||
prmDial.DialTimeout = x.opts.DialTimeout
|
prmDial.DialTimeout = x.opts.DialTimeout
|
||||||
|
|
Loading…
Reference in a new issue