transport/grpc: replace deprecated grpc.WithTimeout() (#1822)
This commit is contained in:
parent
4e7621da18
commit
040577fb74
@ -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
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user