From 8b1a5e3c74b5bf742a2b25f715c28841a7a02c16 Mon Sep 17 00:00:00 2001 From: crusader Date: Fri, 1 Dec 2017 16:29:32 +0900 Subject: [PATCH] ing --- gateway/servlet_handlers.go | 7 +++++++ registry.go => registry/registry.go | 18 ++++-------------- service_map.go => registry/service_map.go | 2 +- server/servlet_handlers.go | 3 ++- servlet.go | 2 +- servlet_handlers.go | 2 +- 6 files changed, 16 insertions(+), 18 deletions(-) rename registry.go => registry/registry.go (96%) rename service_map.go => registry/service_map.go (99%) diff --git a/gateway/servlet_handlers.go b/gateway/servlet_handlers.go index 6654cea..62a28a4 100644 --- a/gateway/servlet_handlers.go +++ b/gateway/servlet_handlers.go @@ -1,9 +1,16 @@ package gateway import ( + "fmt" + "git.loafle.net/commons_go/rpc" + "git.loafle.net/commons_go/rpc/protocol" ) type ServletHandlers struct { rpc.ServletHandlers } + +func (sh *ServletHandlers) Invoke(servletCTX rpc.ServletContext, requestCodec protocol.RegistryCodec) (result interface{}, err error) { + return nil, fmt.Errorf("RPC Gateway Servlet Handler: Invoke is not implemented") +} diff --git a/registry.go b/registry/registry.go similarity index 96% rename from registry.go rename to registry/registry.go index b4044c5..4d146f2 100644 --- a/registry.go +++ b/registry/registry.go @@ -1,4 +1,4 @@ -package rpc +package registry import ( "reflect" @@ -6,27 +6,17 @@ import ( "git.loafle.net/commons_go/rpc/protocol" ) -/** - -Network connection - Handshake(1..n) - Send request - HTTP - - -*/ - // NewRPCRegistry returns a new RPC registry. -func NewRegistry() Registry { +func NewRPCRegistry() RPCRegistry { return &rpcRegistry{ services: new(serviceMap), } } -type Registry interface { +type RPCRegistry interface { + Invoke(codec protocol.RegistryCodec) (result interface{}, err error) RegisterService(receiver interface{}, name string) error HasMethod(method string) bool - Invoke(codec protocol.RegistryCodec) (result interface{}, err error) } // RPCRegistry serves registered RPC services using registered codecs. diff --git a/service_map.go b/registry/service_map.go similarity index 99% rename from service_map.go rename to registry/service_map.go index 9a249bb..9eb1803 100644 --- a/service_map.go +++ b/registry/service_map.go @@ -1,4 +1,4 @@ -package rpc +package registry import ( "fmt" diff --git a/server/servlet_handlers.go b/server/servlet_handlers.go index bfd74eb..351e7a4 100644 --- a/server/servlet_handlers.go +++ b/server/servlet_handlers.go @@ -6,12 +6,13 @@ import ( "git.loafle.net/commons_go/logging" "git.loafle.net/commons_go/rpc" "git.loafle.net/commons_go/rpc/protocol" + "git.loafle.net/commons_go/rpc/registry" ) type ServletHandlers struct { rpc.ServletHandlers - RPCRegistry rpc.Registry + RPCRegistry registry.RPCRegistry } func (sh *ServletHandlers) Invoke(servletCTX rpc.ServletContext, requestCodec protocol.RegistryCodec) (result interface{}, err error) { diff --git a/servlet.go b/servlet.go index 6c6d6f6..cf2ad14 100644 --- a/servlet.go +++ b/servlet.go @@ -70,9 +70,9 @@ func (s *rpcServlet) Start(parentCTX cuc.Context, conn interface{}, doneChan cha if err := s.sh.Init(s.ctx); nil != err { logging.Logger().Panic(fmt.Sprintf("Servlet: Initialization of servlet has been failed %v", err)) } + s.responseQueueChan = make(chan *responseState, s.sh.GetPendingResponses()) s.stopChan = make(chan struct{}) - s.responseQueueChan = make(chan *responseState, s.sh.GetPendingResponses()) s.stopWg.Add(1) go handleServlet(s) diff --git a/servlet_handlers.go b/servlet_handlers.go index 1f95a8b..4fd8bea 100644 --- a/servlet_handlers.go +++ b/servlet_handlers.go @@ -30,7 +30,7 @@ func (sh *ServletHandlers) Init(servletCTX ServletContext) error { } func (sh *ServletHandlers) Invoke(servletCTX ServletContext, requestCodec protocol.RegistryCodec) (result interface{}, err error) { - return nil, fmt.Errorf("Servlet Handler: Invoke is not implemented") + return nil, nil } func (sh *ServletHandlers) Destroy(servletCTX ServletContext) {