From 3893ca67ac0c51e240c23389000f2659fcea1dab Mon Sep 17 00:00:00 2001 From: Aleksey Savchuk <a.savchuk@yadro.com> Date: Wed, 16 Oct 2024 17:56:58 +0300 Subject: [PATCH] [#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> --- rpc/client/init.go | 2 +- rpc/client/options.go | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/rpc/client/init.go b/rpc/client/init.go index be8d066..e7d4398 100644 --- a/rpc/client/init.go +++ b/rpc/client/init.go @@ -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 diff --git a/rpc/client/options.go b/rpc/client/options.go index 5711cd4..755b88b 100644 --- a/rpc/client/options.go +++ b/rpc/client/options.go @@ -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...) + } +}