[#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, StreamName: info.Name,
ServerStreams: info.ServerStream(), ServerStreams: info.ServerStream(),
ClientStreams: info.ClientStream(), ClientStreams: info.ClientStream(),
}, toMethodName(info)) }, toMethodName(info), c.grpcCallOpts...)
if err != nil { if err != nil {
cancel() cancel()
return nil, err return nil, err

View file

@ -24,6 +24,7 @@ type cfg struct {
tlsCfg *tls.Config tlsCfg *tls.Config
grpcDialOpts []grpc.DialOption grpcDialOpts []grpc.DialOption
grpcCallOpts []grpc.CallOption
conn Conn conn Conn
} }
@ -127,3 +128,10 @@ func WithGRPCDialOptions(opts []grpc.DialOption) Option {
c.grpcDialOpts = append(c.grpcDialOpts, opts...) 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...)
}
}