Rename to hdlrWrappers for symmetry sake

This commit is contained in:
Asim 2015-12-02 21:12:09 +00:00
parent 96d7975052
commit 5e364693ee
6 changed files with 34 additions and 36 deletions

View File

@ -8,18 +8,18 @@ import (
)
type options struct {
codecs map[string]codec.NewCodec
broker broker.Broker
registry registry.Registry
transport transport.Transport
metadata map[string]string
name string
address string
advertise string
id string
version string
wrappers []HandlerWrapper
subWrappers []SubscriberWrapper
codecs map[string]codec.NewCodec
broker broker.Broker
registry registry.Registry
transport transport.Transport
metadata map[string]string
name string
address string
advertise string
id string
version string
hdlrWrappers []HandlerWrapper
subWrappers []SubscriberWrapper
}
func newOptions(opt ...Option) options {
@ -159,7 +159,7 @@ func Metadata(md map[string]string) Option {
// Adds a handler Wrapper to a list of options passed into the server
func WrapHandler(w HandlerWrapper) Option {
return func(o *options) {
o.wrappers = append(o.wrappers, w)
o.hdlrWrappers = append(o.hdlrWrappers, w)
}
}

View File

@ -5,7 +5,7 @@ type rpcRequest struct {
method string
contentType string
request interface{}
stream bool
stream bool
}
type rpcPublication struct {

View File

@ -32,9 +32,9 @@ func newRpcServer(opts ...Option) Server {
return &rpcServer{
opts: options,
rpc: &server{
name: options.name,
serviceMap: make(map[string]*service),
wrappers: options.wrappers,
name: options.name,
serviceMap: make(map[string]*service),
hdlrWrappers: options.hdlrWrappers,
},
handlers: make(map[string]Handler),
subscribers: make(map[*subscriber][]broker.Subscriber),

View File

@ -69,14 +69,14 @@ type response struct {
// server represents an RPC Server.
type server struct {
name string
mu sync.Mutex // protects the serviceMap
serviceMap map[string]*service
reqLock sync.Mutex // protects freeReq
freeReq *request
respLock sync.Mutex // protects freeResp
freeResp *response
wrappers []HandlerWrapper
name string
mu sync.Mutex // protects the serviceMap
serviceMap map[string]*service
reqLock sync.Mutex // protects freeReq
freeReq *request
respLock sync.Mutex // protects freeResp
freeResp *response
hdlrWrappers []HandlerWrapper
}
// Is this an exported - upper case - name?
@ -238,10 +238,10 @@ func (s *service) call(ctx context.Context, server *server, sending *sync.Mutex,
var returnValues []reflect.Value
r := &rpcRequest{
service: s.name,
service: s.name,
contentType: ct,
method: req.ServiceMethod,
request: argv.Interface(),
method: req.ServiceMethod,
request: argv.Interface(),
}
if !mtype.stream {
@ -256,8 +256,8 @@ func (s *service) call(ctx context.Context, server *server, sending *sync.Mutex,
return nil
}
for i := len(server.wrappers); i > 0; i-- {
fn = server.wrappers[i-1](fn)
for i := len(server.hdlrWrappers); i > 0; i-- {
fn = server.hdlrWrappers[i-1](fn)
}
errmsg := ""
@ -266,7 +266,6 @@ func (s *service) call(ctx context.Context, server *server, sending *sync.Mutex,
errmsg = err.Error()
}
server.sendResponse(sending, req, replyv.Interface(), codec, errmsg, true)
server.freeRequest(req)
return
@ -323,8 +322,8 @@ func (s *service) call(ctx context.Context, server *server, sending *sync.Mutex,
return nil
}
for i := len(server.wrappers); i > 0; i-- {
fn = server.wrappers[i-1](fn)
for i := len(server.hdlrWrappers); i > 0; i-- {
fn = server.hdlrWrappers[i-1](fn)
}
// client.Stream request

View File

@ -31,7 +31,6 @@ type Server interface {
Stop() error
}
type Publication interface {
Topic() string
Message() interface{}

View File

@ -220,9 +220,9 @@ func (s *rpcServer) createSubHandler(sb *subscriber, opts options) broker.Handle
}
go fn(ctx, &rpcPublication{
topic: sb.topic,
topic: sb.topic,
contentType: ct,
message: req.Interface(),
message: req.Interface(),
})
}
}