mirror of
https://github.com/zeromicro/go-zero.git
synced 2026-05-07 15:10:01 +08:00
feat(zrpc): change NonBlock default to true following gRPC best practices (#5259)
This commit is contained in:
@@ -21,6 +21,9 @@ var (
|
||||
WithDialOption = internal.WithDialOption
|
||||
// WithNonBlock sets the dialing to be nonblock.
|
||||
WithNonBlock = internal.WithNonBlock
|
||||
// WithBlock sets the dialing to be blocking.
|
||||
// Deprecated: blocking dials are not recommended by gRPC.
|
||||
WithBlock = internal.WithBlock
|
||||
// WithStreamClientInterceptor is an alias of internal.WithStreamClientInterceptor.
|
||||
WithStreamClientInterceptor = internal.WithStreamClientInterceptor
|
||||
// WithTimeout is an alias of internal.WithTimeout.
|
||||
@@ -61,6 +64,8 @@ func NewClient(c RpcClientConf, options ...ClientOption) (Client, error) {
|
||||
}
|
||||
if c.NonBlock {
|
||||
opts = append(opts, WithNonBlock())
|
||||
} else {
|
||||
opts = append(opts, WithBlock())
|
||||
}
|
||||
if c.Timeout > 0 {
|
||||
opts = append(opts, WithTimeout(time.Duration(c.Timeout)*time.Millisecond))
|
||||
|
||||
Reference in New Issue
Block a user