[#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

Those options are used when creating a new grc.ClientStream.

Signed-off-by: Aleksey Savchuk <a.savchuk@yadro.com>
This commit is contained in:
Aleksey Savchuk 2024-10-16 17:56:58 +03:00
parent 505c2ee13b
commit 2af8c4a1fc
Signed by: a-savchuk
GPG key ID: 70C0A7FF6F9C4639
2 changed files with 9 additions and 1 deletions

View file

@ -55,7 +55,7 @@ func (c *Client) Init(info common.CallMethodInfo, opts ...CallOption) (MessageRe
StreamName: info.Name,
ServerStreams: info.ServerStream(),
ClientStreams: info.ClientStream(),
}, toMethodName(info))
}, toMethodName(info), c.grpcCallOpts...)
if err != nil {
cancel()
return nil, err

View file

@ -24,6 +24,7 @@ type cfg struct {
tlsCfg *tls.Config
grpcDialOpts []grpc.DialOption
grpcCallOpts []grpc.CallOption
conn Conn
}
@ -127,3 +128,10 @@ func WithGRPCDialOptions(opts []grpc.DialOption) Option {
c.grpcDialOpts = append(c.grpcDialOpts, opts...)
}
}
// WithGRPCDialOptions returns an option to specify grpc.Call.
func WithGRPCCallOptions(opts []grpc.CallOption) Option {
return func(c *cfg) {
c.grpcCallOpts = append(c.grpcCallOpts, opts...)
}
}