transport/grpc: replace deprecated grpc.WithTimeout() (#1822)

This commit is contained in:
Lars Lehtonen 2020-07-12 23:35:53 -07:00 committed by GitHub
parent 4e7621da18
commit 040577fb74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -94,9 +94,7 @@ func (t *grpcTransport) Dial(addr string, opts ...transport.DialOption) (transpo
opt(&dopts) opt(&dopts)
} }
options := []grpc.DialOption{ options := []grpc.DialOption{}
grpc.WithTimeout(dopts.Timeout),
}
if t.opts.Secure || t.opts.TLSConfig != nil { if t.opts.Secure || t.opts.TLSConfig != nil {
config := t.opts.TLSConfig config := t.opts.TLSConfig
@ -112,7 +110,9 @@ func (t *grpcTransport) Dial(addr string, opts ...transport.DialOption) (transpo
} }
// dial the server // 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 { if err != nil {
return nil, err return nil, err
} }