-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rpc/client: Use dial timeout properly #419
rpc/client: Use dial timeout properly #419
Conversation
In previous implementation `Client` didn't block until the connection is up on dial stage. This caused the dial timeout to have no effect. Provide `WithBlock` dial option to `DialContext` call in `openGRPCConn` method. From now `Client` blocks for configured timeout until the connection is up. Signed-off-by: Leonard Lyubich <ctulhurider@gmail.com>
In previous implementation `Client` passed `context.Background()` to `grpc.DialContext` function. This didn't allow to abort dial stage by the given context. Base dial context on the one provided with `WithContext` option. Fall back to using `context.Background` if context is not specified. Signed-off-by: Leonard Lyubich <ctulhurider@gmail.com>
4563c7f
to
3bdb3a4
Compare
Codecov Report
@@ Coverage Diff @@
## master #419 +/- ##
==========================================
- Coverage 63.75% 63.21% -0.54%
==========================================
Files 75 75
Lines 9349 9355 +6
==========================================
- Hits 5960 5914 -46
- Misses 2671 2729 +58
+ Partials 718 712 -6
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
BTW, you may want to enable |
rpc/client/connect.go
Outdated
cancel() | ||
if err != nil { | ||
return fmt.Errorf("open gRPC client connection: %w", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function is called open
, may be it is better to wrap on the caller side?
rpc/client/call_options.go
Outdated
return &callParameters{ | ||
callOpts: make([]grpc.CallOption, 0, 1), | ||
} | ||
return &callParameters{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use context.Background
as default?
In previous implementation `Client` passed `context.Background()` to `grpc.DialContext` function. This didn't allow to abort dial stage by the given context. Base dial context on the one provided with `WithContext` option. Fall back to using `context.Background` if context is not specified. Signed-off-by: Leonard Lyubich <ctulhurider@gmail.com>
3bdb3a4
to
62298db
Compare
In previous implementation `Client` didn't block until the connection is up on dial stage. This caused the dial timeout to have no effect. Provide `WithBlock` dial option to `DialContext` call in `openGRPCConn` method. From now `Client` blocks for configured timeout until the connection is up. Signed-off-by: Leonard Lyubich <ctulhurider@gmail.com>
No description provided.