WIP: rpc/client: Allow to pass custom grpc.CallOption options #124

Closed
a-savchuk wants to merge 3 commits from a-savchuk/frostfs-api-go:grpc-call-options into master
Member

Signed-off-by: Aleksey Savchuk a.savchuk@yadro.com

Signed-off-by: Aleksey Savchuk <a.savchuk@yadro.com>
a-savchuk added 3 commits 2024-10-16 15:00:12 +00:00
Signed-off-by: Aleksey Savchuk <a.savchuk@yadro.com>
Add the following targets:
- `pre-commit` to install pre-commit hooks
- `unpre-commit` to uninstall pre-commit hooks
- `pre-commit-run` to run pre-commit hooks

Signed-off-by: Aleksey Savchuk <a.savchuk@yadro.com>
[#xx] rpc/client: Allow to pass custom grpc.CallOption options
Some checks failed
Tests and linters / Lint (pull_request) Successful in 50s
DCO action / DCO (pull_request) Failing after 1m9s
Tests and linters / Tests (pull_request) Successful in 1m11s
Tests and linters / Tests with -race (pull_request) Successful in 1m12s
2af8c4a1fc
Those options are used when creating a new grc.ClientStream.

Signed-off-by: Aleksey Savchuk <a.savchuk@yadro.com>
a-savchuk force-pushed grpc-call-options from 2af8c4a1fc to 3893ca67ac 2024-10-16 15:01:34 +00:00 Compare
fyrchik reviewed 2024-10-16 15:31:46 +00:00
@ -56,3 +56,3 @@
ServerStreams: info.ServerStream(),
ClientStreams: info.ClientStream(),
}, toMethodName(info))
}, toMethodName(info), c.grpcCallOpts...)
Owner

These are the call options to be passed to every method?
In this case let's use default word everywhere in names (WithDefaultGRPCCallOptions).
An we already have opts ...CallOption in this function, so this is doubly confusing.

These are the call options to be passed to _every_ method? In this case let's use `default` word everywhere in names (`WithDefaultGRPCCallOptions`). An we already have `opts ...CallOption` in this function, so this is doubly confusing.
Author
Member

Our CallOptions don't use grpc.CallOption underneath. As I see, you use them only while opening a new connection. I'll consider if we can combine them

Lines 14 to 15 in f0fc40e
func SendUnary(cli *Client, info common.CallMethodInfo, req, resp message.Message, opts ...CallOption) error {
rw, err := cli.Init(info, opts...)


Lines 42 to 51 in f0fc40e
func (c *Client) Init(info common.CallMethodInfo, opts ...CallOption) (MessageReadWriter, error) {
prm := defaultCallParameters()
for _, opt := range opts {
opt(prm)
}
if err := c.openGRPCConn(prm.ctx, prm.dialer); err != nil {
return nil, err
}

Our `CallOption`s don't use `grpc.CallOption` underneath. As I see, you use them only while opening a new connection. I'll consider if we can combine them https://git.frostfs.info/TrueCloudLab/frostfs-api-go/src/commit/f0fc40e116d13869bb8a21761749d7666137e15b/rpc/client/flows.go#L14-L15 https://git.frostfs.info/TrueCloudLab/frostfs-api-go/src/commit/f0fc40e116d13869bb8a21761749d7666137e15b/rpc/client/init.go#L42-L51
@ -24,6 +24,7 @@ type cfg struct {
tlsCfg *tls.Config
grpcDialOpts []grpc.DialOption
grpcCallOpts []grpc.CallOption
Owner

What is the usecase?

What is the usecase?
Author
Member

It's WIP yet. I was going to describe entire solution later. In short. I'd like to pass grpc.WaitForReady(true) to a client to make it wait for a deadline.

It's WIP yet. I was going to describe entire solution later. In short. I'd like to pass `grpc.WaitForReady(true)` to a client to make it wait for a deadline.
Owner
  1. Please, no links to anything unaccessible to a general public.

to make it wait for a deadline

For every call? I think the default behaviour makes sense for some calls. Also, what is the timeout we wait for without this option?

1. Please, no links to anything unaccessible to a general public. 2. >to make it wait for a deadline For _every_ call? I think the default behaviour makes sense for some calls. Also, what is the timeout we wait for without this option?
Author
Member

Found a simpler solution, please see TrueCloudLab/frostfs-node#1441

Found a simpler solution, please see https://git.frostfs.info/TrueCloudLab/frostfs-node/pulls/1441
a-savchuk closed this pull request 2024-10-22 07:47:19 +00:00
All checks were successful
Tests and linters / Lint (pull_request) Successful in 46s
DCO action / DCO (pull_request) Successful in 1m4s
Tests and linters / Tests (pull_request) Successful in 1m6s
Tests and linters / Tests with -race (pull_request) Successful in 1m7s

Pull request closed

Sign in to join this conversation.
No description provided.