From 6e91cd5cf5c9fd684253d58e125e6641ef20f9d1 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Thu, 17 Nov 2022 00:00:50 +0300 Subject: [PATCH] add context dialer option Signed-off-by: Vasiliy Tolstov --- grpc.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/grpc.go b/grpc.go index 80e8ed2..bd1b701 100644 --- a/grpc.go +++ b/grpc.go @@ -231,6 +231,14 @@ func (g *grpcClient) stream(ctx context.Context, addr string, req client.Request grpcDialOptions = append(grpcDialOptions, opts...) } + contextDialer := g.opts.ContextDialer + if opts.ContextDialer != nil { + contextDialer = opts.ContextDialer + } + if contextDialer != nil { + grpcDialOptions = append(grpcDialOptions, grpc.WithContextDialer(contextDialer)) + } + cc, err := g.pool.getConn(dialCtx, addr, grpcDialOptions...) if err != nil { return errors.InternalServerError("go.micro.client", fmt.Sprintf("Error sending request: %v", err))