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

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 88789d5f4a
commit 3893ca67ac
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...)
}
}