From f3b591d722d63f8fab394b8659516a5b9b8b073d Mon Sep 17 00:00:00 2001 From: Asim Date: Mon, 7 Nov 2016 17:58:34 +0000 Subject: [PATCH] Strip stream func and rename call wrappers... --- client/client_wrapper.go | 10 ++-------- client/options.go | 12 ++++++------ client/rpc_client.go | 4 ++-- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/client/client_wrapper.go b/client/client_wrapper.go index 099f90be..c10a8009 100644 --- a/client/client_wrapper.go +++ b/client/client_wrapper.go @@ -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 diff --git a/client/options.go b/client/options.go index 832a7db3..a5093db9 100644 --- a/client/options.go +++ b/client/options.go @@ -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...) } } diff --git a/client/rpc_client.go b/client/rpc_client.go index 17e51fb0..ee40728f 100644 --- a/client/rpc_client.go +++ b/client/rpc_client.go @@ -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