Skip to content

Commit 4d70eab

Browse files
authored
Merge pull request #564 from ydb-platform/grpc-dial
fixed grpc dial - make grpc dial options on real dial stage
2 parents 9fc43dc + 6811f45 commit 4d70eab

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

internal/conn/conn.go

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ func (c *conn) Address() string {
5353
type conn struct {
5454
mtx sync.RWMutex
5555
config Config // ro access
56-
grpcDialOptions []grpc.DialOption
5756
cc *grpc.ClientConn
5857
done chan struct{}
5958
endpoint endpoint.Endpoint // ro access
@@ -200,7 +199,11 @@ func (c *conn) take(ctx context.Context) (cc *grpc.ClientConn, err error) {
200199
// three slashes in "ydb:///" is ok. It needs for good parse scheme in grpc resolver.
201200
address := "ydb:///" + c.endpoint.Address()
202201

203-
cc, err = grpc.DialContext(ctx, address, c.grpcDialOptions...)
202+
cc, err = grpc.DialContext(ctx, address, append(
203+
[]grpc.DialOption{
204+
grpc.WithStatsHandler(statsHandler{}),
205+
}, c.config.GrpcDialOptions()...,
206+
)...)
204207
if err != nil {
205208
err = xerrors.WithStackTrace(
206209
xerrors.Retryable(
@@ -461,20 +464,11 @@ func withOnTransportError(onTransportError func(ctx context.Context, cc Conn, ca
461464
}
462465

463466
func newConn(e endpoint.Endpoint, config Config, opts ...option) *conn {
464-
grpcDialOptions := config.GrpcDialOptions()
465-
grpcDialOptions = append(
466-
append(
467-
make([]grpc.DialOption, 0, len(grpcDialOptions)+1),
468-
statsHandlerOption,
469-
),
470-
grpcDialOptions...,
471-
)
472467
c := &conn{
473-
grpcDialOptions: grpcDialOptions,
474-
state: uint32(Created),
475-
endpoint: e,
476-
config: config,
477-
done: make(chan struct{}),
468+
state: uint32(Created),
469+
endpoint: e,
470+
config: config,
471+
done: make(chan struct{}),
478472
}
479473
for _, o := range opts {
480474
if o != nil {
@@ -493,8 +487,6 @@ var _ stats.Handler = statsHandler{}
493487

494488
type statsHandler struct{}
495489

496-
var statsHandlerOption = grpc.WithStatsHandler(statsHandler{})
497-
498490
func (statsHandler) TagRPC(ctx context.Context, _ *stats.RPCTagInfo) context.Context {
499491
return ctx
500492
}

0 commit comments

Comments
 (0)