Skip to content

Commit

Permalink
Strip stream func and rename call wrappers...
Browse files Browse the repository at this point in the history
  • Loading branch information
Asim committed Nov 7, 2016
1 parent 5ee585e commit f3b591d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
10 changes: 2 additions & 8 deletions client/client_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 6 additions & 6 deletions client/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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...)
}
}

Expand Down Expand Up @@ -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...)
}
}

Expand Down
4 changes: 2 additions & 2 deletions client/rpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f3b591d

Please sign in to comment.