From 040577fb746feafd5350c65384cf0dad73d4d743 Mon Sep 17 00:00:00 2001 From: Lars Lehtonen Date: Sun, 12 Jul 2020 23:35:53 -0700 Subject: [PATCH] transport/grpc: replace deprecated grpc.WithTimeout() (#1822) --- transport/grpc/grpc.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/transport/grpc/grpc.go b/transport/grpc/grpc.go index 58f5cfd7..23c5d095 100644 --- a/transport/grpc/grpc.go +++ b/transport/grpc/grpc.go @@ -94,9 +94,7 @@ func (t *grpcTransport) Dial(addr string, opts ...transport.DialOption) (transpo opt(&dopts) } - options := []grpc.DialOption{ - grpc.WithTimeout(dopts.Timeout), - } + options := []grpc.DialOption{} if t.opts.Secure || t.opts.TLSConfig != nil { config := t.opts.TLSConfig @@ -112,7 +110,9 @@ func (t *grpcTransport) Dial(addr string, opts ...transport.DialOption) (transpo } // dial the server - conn, err := grpc.Dial(addr, options...) + ctx, cancel := context.WithTimeout(context.Background(), dopts.Timeout) + defer cancel() + conn, err := grpc.DialContext(ctx, addr, options...) if err != nil { return nil, err }