Strip stream func and rename call wrappers...
This commit is contained in:
parent
5ee585e77d
commit
f3b591d722
@ -41,17 +41,11 @@ import (
|
||||
// CallFunc represents the individual call func
|
||||
type CallFunc func(ctx context.Context, address string, req Request, rsp interface{}, opts CallOptions) error
|
||||
|
||||
// StreamFunc represents the individual stream func
|
||||
type StreamFunc func(ctx context.Context, address string, req Request, opts CallOptions) (Streamer, error)
|
||||
// CallWrapper is a low level wrapper for the CallFunc
|
||||
type CallWrapper func(CallFunc) CallFunc
|
||||
|
||||
// Wrapper wraps a client and returns a client
|
||||
type Wrapper func(Client) Client
|
||||
|
||||
// StreamWrapper wraps a Stream and returns the equivalent
|
||||
type StreamWrapper func(Streamer) Streamer
|
||||
|
||||
// CallFuncWrapper is a low level wrapper for the CallFunc
|
||||
type CallFuncWrapper func(CallFunc) CallFunc
|
||||
|
||||
// StreamFuncWrapper is a low level wrapper for the StreamFunc
|
||||
type StreamFuncWrapper func(StreamFunc) StreamFunc
|
||||
|
@ -53,7 +53,7 @@ type CallOptions struct {
|
||||
RequestTimeout time.Duration
|
||||
|
||||
// Middleware for low level call func
|
||||
CallFuncWrappers []CallFuncWrapper
|
||||
CallWrappers []CallWrapper
|
||||
|
||||
// Other options for implementations of the interface
|
||||
// can be stored in a context
|
||||
@ -181,9 +181,9 @@ func Wrap(w Wrapper) Option {
|
||||
}
|
||||
|
||||
// Adds a Wrapper to the list of CallFunc wrappers
|
||||
func WrapCallFunc(cw ...CallFuncWrapper) Option {
|
||||
func WrapCallFunc(cw ...CallWrapper) Option {
|
||||
return func(o *Options) {
|
||||
o.CallOptions.CallFuncWrappers = append(o.CallOptions.CallFuncWrappers, cw...)
|
||||
o.CallOptions.CallWrappers = append(o.CallOptions.CallWrappers, cw...)
|
||||
}
|
||||
}
|
||||
|
||||
@ -226,10 +226,10 @@ func WithSelectOption(so ...selector.SelectOption) CallOption {
|
||||
}
|
||||
}
|
||||
|
||||
// WithCallFuncWrapper is a CallOption which adds to the existing CallFunc wrappers
|
||||
func WithCallFuncWrapper(cw ...CallFuncWrapper) CallOption {
|
||||
// WithCallWrapper is a CallOption which adds to the existing CallFunc wrappers
|
||||
func WithCallWrapper(cw ...CallWrapper) CallOption {
|
||||
return func(o *CallOptions) {
|
||||
o.CallFuncWrappers = append(o.CallFuncWrappers, cw...)
|
||||
o.CallWrappers = append(o.CallWrappers, cw...)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -279,8 +279,8 @@ func (r *rpcClient) Call(ctx context.Context, request Request, response interfac
|
||||
|
||||
// wrap the call in reverse
|
||||
rcall := r.call
|
||||
for i := len(callOpts.CallFuncWrappers); i > 0; i-- {
|
||||
rcall = callOpts.CallFuncWrappers[i-1](rcall)
|
||||
for i := len(callOpts.CallWrappers); i > 0; i-- {
|
||||
rcall = callOpts.CallWrappers[i-1](rcall)
|
||||
}
|
||||
|
||||
// make the call
|
||||
|
Loading…
Reference in New Issue
Block a user