Skip to content
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

Merged

Conversation

cthulhu-rider
Copy link
Contributor

No description provided.

@cthulhu-rider cthulhu-rider self-assigned this Oct 3, 2022
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>
cthulhu-rider added a commit to cthulhu-rider/neofs-api-go that referenced this pull request Oct 3, 2022
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>
@codecov
Copy link

codecov bot commented Oct 3, 2022

Codecov Report

Merging #419 (8015df3) into master (504e427) will decrease coverage by 0.53%.
The diff coverage is 0.00%.

❗ Current head 8015df3 differs from pull request most recent head 62298db. Consider uploading reports for the commit 62298db to get more accurate results

@@            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     
Impacted Files Coverage Δ
rpc/client/call_options.go 0.00% <0.00%> (ø)
rpc/client/connect.go 31.81% <0.00%> (-5.03%) ⬇️
rpc/client/init.go 0.00% <0.00%> (ø)
object/marshal.go 69.04% <0.00%> (-5.68%) ⬇️
session/marshal.go 72.66% <0.00%> (-1.39%) ⬇️
object/convert.go 73.92% <0.00%> (-0.92%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@roman-khimov
Copy link
Member

BTW, you may want to enable contextcheck linter (https://github.com/kkHAIKE/contextcheck) in golangci-lint.

carpawell
carpawell previously approved these changes Oct 4, 2022
fyrchik
fyrchik previously approved these changes Oct 4, 2022
cancel()
if err != nil {
return fmt.Errorf("open gRPC client connection: %w", err)
Copy link
Contributor

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?

return &callParameters{
callOpts: make([]grpc.CallOption, 0, 1),
}
return &callParameters{}
Copy link
Contributor

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>
@cthulhu-rider cthulhu-rider merged commit 3a91383 into nspcc-dev:master Oct 5, 2022
cthulhu-rider added a commit that referenced this pull request Oct 5, 2022
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>
@cthulhu-rider cthulhu-rider deleted the bugfix/rpc-client-dial-timeout branch October 5, 2022 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants