[#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/zapcore"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -57,6 +56,7 @@ type InitParameters struct {
|
|||
healthcheckTimeout time.Duration
|
||||
clientRebalanceInterval time.Duration
|
||||
nodeParams []pool.NodeParam
|
||||
dialOptions []grpc.DialOption
|
||||
}
|
||||
|
||||
// Pool represents virtual connection to the FrostFS tree services network to communicate
|
||||
|
@ -72,6 +72,7 @@ type Pool struct {
|
|||
cancel context.CancelFunc
|
||||
closedCh chan struct{}
|
||||
rebalanceParams rebalanceParameters
|
||||
dialOptions []grpc.DialOption
|
||||
logger *zap.Logger
|
||||
|
||||
startIndicesMtx sync.RWMutex
|
||||
|
@ -167,6 +168,7 @@ func NewPool(options InitParameters) (*Pool, error) {
|
|||
p := &Pool{
|
||||
key: options.key,
|
||||
logger: options.logger,
|
||||
dialOptions: options.dialOptions,
|
||||
rebalanceParams: rebalanceParameters{
|
||||
nodesGroup: nodesParams,
|
||||
nodeRequestTimeout: options.healthcheckTimeout,
|
||||
|
@ -192,7 +194,7 @@ func (p *Pool) Dial(ctx context.Context) error {
|
|||
for i, nodes := range p.rebalanceParams.nodesGroup {
|
||||
clients := make([]client, len(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 {
|
||||
p.log(zap.WarnLevel, "failed to build client", zap.String("address", node.Address()), zap.Error(err))
|
||||
continue
|
||||
|
@ -258,6 +260,11 @@ func (x *InitParameters) AddNode(nodeParam pool.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.
|
||||
//
|
||||
// Can return predefined errors:
|
||||
|
|
Loading…
Reference in a new issue