Add call func wrapper
This commit is contained in:
@@ -52,6 +52,9 @@ type CallOptions struct {
|
||||
// Request/Response timeout
|
||||
RequestTimeout time.Duration
|
||||
|
||||
// Middleware for low level call func
|
||||
CallWrappers []CallFuncWrapper
|
||||
|
||||
// Other options for implementations of the interface
|
||||
// can be stored in a context
|
||||
Context context.Context
|
||||
@@ -177,6 +180,13 @@ func Wrap(w Wrapper) Option {
|
||||
}
|
||||
}
|
||||
|
||||
// Adds a Wrapper to the list of CallFunc wrappers
|
||||
func WrapCallFunc(cw ...CallFuncWrapper) Option {
|
||||
return func(o *Options) {
|
||||
o.CallOptions.CallWrappers = append(o.CallOptions.CallWrappers, cw...)
|
||||
}
|
||||
}
|
||||
|
||||
// Backoff is used to set the backoff function used
|
||||
// when retrying Calls
|
||||
func Backoff(fn BackoffFunc) Option {
|
||||
@@ -216,6 +226,13 @@ func WithSelectOption(so ...selector.SelectOption) CallOption {
|
||||
}
|
||||
}
|
||||
|
||||
// WithCallFuncWrapper is a CallOption which adds to the existing CallFunc wrappers
|
||||
func WithCallFuncWrapper(cw ...CallFuncWrapper) CallOption {
|
||||
return func(o *CallOptions) {
|
||||
o.CallWrappers = append(o.CallWrappers, cw...)
|
||||
}
|
||||
}
|
||||
|
||||
// WithBackoff is a CallOption which overrides that which
|
||||
// set in Options.CallOptions
|
||||
func WithBackoff(fn BackoffFunc) CallOption {
|
||||
|
Reference in New Issue
Block a user