client: allow to create new client with predefined call options
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
23
client/client_call_options.go
Normal file
23
client/client_call_options.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
type clientCallOptions struct {
|
||||
Client
|
||||
opts []CallOption
|
||||
}
|
||||
|
||||
func (s *clientCallOptions) Call(ctx context.Context, req Request, rsp interface{}, opts ...CallOption) error {
|
||||
return s.Client.Call(ctx, req, rsp, append(s.opts, opts...)...)
|
||||
}
|
||||
|
||||
func (s *clientCallOptions) Stream(ctx context.Context, req Request, opts ...CallOption) (Stream, error) {
|
||||
return s.Client.Stream(ctx, req, append(s.opts, opts...)...)
|
||||
}
|
||||
|
||||
// NewClientCallOptions add CallOption to every call
|
||||
func NewClientCallOptions(c Client, opts ...CallOption) Client {
|
||||
return &clientCallOptions{c, opts}
|
||||
}
|
||||
Reference in New Issue
Block a user