Skip to content
This repository has been archived by the owner on Dec 27, 2024. It is now read-only.

Commit

Permalink
rpc/client: Fail fast on any non-temporary dial error
Browse files Browse the repository at this point in the history
Previously, RPC client unconditionally blocked by context passed into
`WithContext` (e.g. for 15s). In particular, it definitely stuck on
non-temporary error encounter. An example of such errors could be an
incorrect network address or connection refusal.

Now client instantly fails with any irreparable error in which it is
pointless to wait for a change in the connection state. This is achieved
with `grpcstd.FailOnNonTempDialError(true)` option.

Signed-off-by: Leonard Lyubich <[email protected]>
  • Loading branch information
cthulhu-rider committed Feb 28, 2024
1 parent 05ac62e commit 2844227
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion rpc/client/connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ func (c *Client) openGRPCConn(ctx context.Context, extraDialOpts ...grpcstd.Dial
dialCtx, cancel := context.WithTimeout(ctx, c.dialTimeout)
var err error

dialOpts := make([]grpcstd.DialOption, 0, 2+len(extraDialOpts))
dialOpts := make([]grpcstd.DialOption, 0, 3+len(extraDialOpts))
dialOpts = append(dialOpts,
grpcstd.WithTransportCredentials(creds),
grpcstd.WithReturnConnectionError(),
grpcstd.FailOnNonTempDialError(true),
)
if extraDialOpts != nil {
dialOpts = append(dialOpts, extraDialOpts...)
Expand Down

0 comments on commit 2844227

Please sign in to comment.