forked from TrueCloudLab/frostfs-sdk-go
[#84] pool/tree: Allow to pass gRPC dial options
Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
This commit is contained in:
parent
981d24a493
commit
af40dc68f0
1 changed files with 11 additions and 4 deletions
|
@ -17,7 +17,6 @@ import (
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"go.uber.org/zap/zapcore"
|
"go.uber.org/zap/zapcore"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/credentials/insecure"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -57,6 +56,7 @@ type InitParameters struct {
|
||||||
healthcheckTimeout time.Duration
|
healthcheckTimeout time.Duration
|
||||||
clientRebalanceInterval time.Duration
|
clientRebalanceInterval time.Duration
|
||||||
nodeParams []pool.NodeParam
|
nodeParams []pool.NodeParam
|
||||||
|
dialOptions []grpc.DialOption
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pool represents virtual connection to the FrostFS tree services network to communicate
|
// Pool represents virtual connection to the FrostFS tree services network to communicate
|
||||||
|
@ -72,6 +72,7 @@ type Pool struct {
|
||||||
cancel context.CancelFunc
|
cancel context.CancelFunc
|
||||||
closedCh chan struct{}
|
closedCh chan struct{}
|
||||||
rebalanceParams rebalanceParameters
|
rebalanceParams rebalanceParameters
|
||||||
|
dialOptions []grpc.DialOption
|
||||||
logger *zap.Logger
|
logger *zap.Logger
|
||||||
|
|
||||||
startIndicesMtx sync.RWMutex
|
startIndicesMtx sync.RWMutex
|
||||||
|
@ -165,8 +166,9 @@ func NewPool(options InitParameters) (*Pool, error) {
|
||||||
fillDefaultInitParams(&options)
|
fillDefaultInitParams(&options)
|
||||||
|
|
||||||
p := &Pool{
|
p := &Pool{
|
||||||
key: options.key,
|
key: options.key,
|
||||||
logger: options.logger,
|
logger: options.logger,
|
||||||
|
dialOptions: options.dialOptions,
|
||||||
rebalanceParams: rebalanceParameters{
|
rebalanceParams: rebalanceParameters{
|
||||||
nodesGroup: nodesParams,
|
nodesGroup: nodesParams,
|
||||||
nodeRequestTimeout: options.healthcheckTimeout,
|
nodeRequestTimeout: options.healthcheckTimeout,
|
||||||
|
@ -192,7 +194,7 @@ func (p *Pool) Dial(ctx context.Context) error {
|
||||||
for i, nodes := range p.rebalanceParams.nodesGroup {
|
for i, nodes := range p.rebalanceParams.nodesGroup {
|
||||||
clients := make([]client, len(nodes))
|
clients := make([]client, len(nodes))
|
||||||
for j, node := range nodes {
|
for j, node := range nodes {
|
||||||
clients[j] = newTreeClient(node.Address(), grpc.WithTransportCredentials(insecure.NewCredentials()))
|
clients[j] = newTreeClient(node.Address(), p.dialOptions...)
|
||||||
if err := clients[j].dial(ctx); err != nil {
|
if err := clients[j].dial(ctx); err != nil {
|
||||||
p.log(zap.WarnLevel, "failed to build client", zap.String("address", node.Address()), zap.Error(err))
|
p.log(zap.WarnLevel, "failed to build client", zap.String("address", node.Address()), zap.Error(err))
|
||||||
continue
|
continue
|
||||||
|
@ -258,6 +260,11 @@ func (x *InitParameters) AddNode(nodeParam pool.NodeParam) {
|
||||||
x.nodeParams = append(x.nodeParams, nodeParam)
|
x.nodeParams = append(x.nodeParams, nodeParam)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetGRPCDialOptions sets the gRPC dial options for new gRPC tree client connection.
|
||||||
|
func (x *InitParameters) SetGRPCDialOptions(opts ...grpc.DialOption) {
|
||||||
|
x.dialOptions = opts
|
||||||
|
}
|
||||||
|
|
||||||
// GetNodes invokes eponymous method from TreeServiceClient.
|
// GetNodes invokes eponymous method from TreeServiceClient.
|
||||||
//
|
//
|
||||||
// Can return predefined errors:
|
// Can return predefined errors:
|
||||||
|
|
Loading…
Reference in a new issue