forked from TrueCloudLab/frostfs-node
[#809] client: Refactor PrmInit, PrmDial usage
Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
This commit is contained in:
parent
76ff26039c
commit
02454df14a
4 changed files with 38 additions and 38 deletions
44
pkg/network/cache/multi.go
vendored
44
pkg/network/cache/multi.go
vendored
|
@ -51,42 +51,40 @@ func newMultiClient(addr network.AddressGroup, opts ClientCacheOpts) *multiClien
|
|||
}
|
||||
|
||||
func (x *multiClient) createForAddress(ctx context.Context, addr network.Address) (clientcore.Client, error) {
|
||||
var (
|
||||
c client.Client
|
||||
prmInit client.PrmInit
|
||||
prmDial client.PrmDial
|
||||
)
|
||||
|
||||
prmInit.DisableFrostFSFailuresResolution()
|
||||
prmDial.SetServerURI(addr.URIAddr())
|
||||
var c client.Client
|
||||
|
||||
prmInit := client.PrmInit{
|
||||
DisableFrostFSErrorResolution: true,
|
||||
}
|
||||
if x.opts.Key != nil {
|
||||
prmInit.SetDefaultPrivateKey(*x.opts.Key)
|
||||
prmInit.Key = *x.opts.Key
|
||||
}
|
||||
|
||||
prmDial := client.PrmDial{
|
||||
Endpoint: addr.URIAddr(),
|
||||
GRPCDialOptions: []grpc.DialOption{
|
||||
grpc.WithChainUnaryInterceptor(
|
||||
metrics.NewUnaryClientInterceptor(),
|
||||
tracing.NewUnaryClientInteceptor(),
|
||||
),
|
||||
grpc.WithChainStreamInterceptor(
|
||||
metrics.NewStreamClientInterceptor(),
|
||||
tracing.NewStreamClientInterceptor(),
|
||||
),
|
||||
},
|
||||
}
|
||||
if x.opts.DialTimeout > 0 {
|
||||
prmDial.SetTimeout(x.opts.DialTimeout)
|
||||
prmDial.DialTimeout = x.opts.DialTimeout
|
||||
}
|
||||
|
||||
if x.opts.StreamTimeout > 0 {
|
||||
prmDial.SetStreamTimeout(x.opts.StreamTimeout)
|
||||
prmDial.StreamTimeout = x.opts.StreamTimeout
|
||||
}
|
||||
|
||||
if x.opts.ResponseCallback != nil {
|
||||
prmInit.SetResponseInfoCallback(x.opts.ResponseCallback)
|
||||
prmInit.ResponseInfoCallback = x.opts.ResponseCallback
|
||||
}
|
||||
|
||||
prmDial.SetGRPCDialOptions(
|
||||
grpc.WithChainUnaryInterceptor(
|
||||
metrics.NewUnaryClientInterceptor(),
|
||||
tracing.NewUnaryClientInteceptor(),
|
||||
),
|
||||
grpc.WithChainStreamInterceptor(
|
||||
metrics.NewStreamClientInterceptor(),
|
||||
tracing.NewStreamClientInterceptor(),
|
||||
),
|
||||
)
|
||||
|
||||
c.Init(prmInit)
|
||||
err := c.Dial(ctx, prmDial)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue