1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-12-24 10:07:04 +02:00

Allow init of wrappers and name. Set server.name for rpc request

This commit is contained in:
Asim 2016-02-18 18:08:43 +00:00
parent 8cd906e75e
commit 8e61057bc9
2 changed files with 12 additions and 3 deletions

View File

@ -112,6 +112,12 @@ func (s *rpcServer) Init(opts ...Option) error {
for _, opt := range opts {
opt(&s.opts)
}
// update internal server
s.rpc = &server{
name: s.opts.Name,
serviceMap: s.rpc.serviceMap,
hdlrWrappers: s.opts.HdlrWrappers,
}
s.Unlock()
return nil
}
@ -121,12 +127,15 @@ func (s *rpcServer) NewHandler(h interface{}, opts ...HandlerOption) Handler {
}
func (s *rpcServer) Handle(h Handler) error {
s.Lock()
defer s.Unlock()
if err := s.rpc.register(h.Handler()); err != nil {
return err
}
s.Lock()
s.handlers[h.Name()] = h
s.Unlock()
return nil
}

View File

@ -234,7 +234,7 @@ func (s *service) call(ctx context.Context, server *server, sending *sync.Mutex,
var returnValues []reflect.Value
r := &rpcRequest{
service: s.name,
service: server.name,
contentType: ct,
method: req.ServiceMethod,
}