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:
parent
8cd906e75e
commit
8e61057bc9
@ -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
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user