documentation: mention DialContext is non-blocking by default (#1970)

This commit is contained in:
Menghan Li 2018-04-12 15:11:22 -07:00 committed by lyuxuan
parent c4a6e7589b
commit 35aeaeb587
1 changed files with 12 additions and 4 deletions

View File

@ -417,10 +417,18 @@ func Dial(target string, opts ...DialOption) (*ClientConn, error) {
return DialContext(context.Background(), target, opts...) return DialContext(context.Background(), target, opts...)
} }
// DialContext creates a client connection to the given target. ctx can be used to // DialContext creates a client connection to the given target. By default, it's
// cancel or expire the pending connection. Once this function returns, the // a non-blocking dial (the function won't wait for connections to be
// cancellation and expiration of ctx will be noop. Users should call ClientConn.Close // established, and connecting happens in the background). To make it a blocking
// to terminate all the pending operations after this function returns. // dial, use WithBlock() dial option.
//
// In the non-blocking case, the ctx does not act against the connection. It
// only controls the setup steps.
//
// In the blocking case, ctx can be used to cancel or expire the pending
// connection. Once this function returns, the cancellation and expiration of
// ctx will be noop. Users should call ClientConn.Close to terminate all the
// pending operations after this function returns.
// //
// The target name syntax is defined in // The target name syntax is defined in
// https://github.com/grpc/grpc/blob/master/doc/naming.md. // https://github.com/grpc/grpc/blob/master/doc/naming.md.