2020-12-15 23:09:51 +03:00
|
|
|
package client
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2023-07-29 00:40:58 +03:00
|
|
|
|
|
|
|
"go.unistack.org/micro/v4/options"
|
2020-12-15 23:09:51 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
type clientCallOptions struct {
|
|
|
|
Client
|
2023-07-29 00:40:58 +03:00
|
|
|
opts []options.Option
|
2020-12-15 23:09:51 +03:00
|
|
|
}
|
|
|
|
|
2023-07-29 00:40:58 +03:00
|
|
|
func (s *clientCallOptions) Call(ctx context.Context, req Request, rsp interface{}, opts ...options.Option) error {
|
2020-12-15 23:09:51 +03:00
|
|
|
return s.Client.Call(ctx, req, rsp, append(s.opts, opts...)...)
|
|
|
|
}
|
|
|
|
|
2023-07-29 00:40:58 +03:00
|
|
|
func (s *clientCallOptions) Stream(ctx context.Context, req Request, opts ...options.Option) (Stream, error) {
|
2020-12-15 23:09:51 +03:00
|
|
|
return s.Client.Stream(ctx, req, append(s.opts, opts...)...)
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewClientCallOptions add CallOption to every call
|
2023-07-29 00:40:58 +03:00
|
|
|
func NewClientCallOptions(c Client, opts ...options.Option) Client {
|
2020-12-15 23:09:51 +03:00
|
|
|
return &clientCallOptions{c, opts}
|
|
|
|
}
|