This commit is contained in:
crusader 2017-12-01 16:29:32 +09:00
parent 38b336e1bb
commit 8b1a5e3c74
6 changed files with 16 additions and 18 deletions

View File

@ -1,9 +1,16 @@
package gateway package gateway
import ( import (
"fmt"
"git.loafle.net/commons_go/rpc" "git.loafle.net/commons_go/rpc"
"git.loafle.net/commons_go/rpc/protocol"
) )
type ServletHandlers struct { type ServletHandlers struct {
rpc.ServletHandlers 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")
}

View File

@ -1,4 +1,4 @@
package rpc package registry
import ( import (
"reflect" "reflect"
@ -6,27 +6,17 @@ import (
"git.loafle.net/commons_go/rpc/protocol" "git.loafle.net/commons_go/rpc/protocol"
) )
/**
Network connection
Handshake(1..n)
Send request
HTTP
*/
// NewRPCRegistry returns a new RPC registry. // NewRPCRegistry returns a new RPC registry.
func NewRegistry() Registry { func NewRPCRegistry() RPCRegistry {
return &rpcRegistry{ return &rpcRegistry{
services: new(serviceMap), services: new(serviceMap),
} }
} }
type Registry interface { type RPCRegistry interface {
Invoke(codec protocol.RegistryCodec) (result interface{}, err error)
RegisterService(receiver interface{}, name string) error RegisterService(receiver interface{}, name string) error
HasMethod(method string) bool HasMethod(method string) bool
Invoke(codec protocol.RegistryCodec) (result interface{}, err error)
} }
// RPCRegistry serves registered RPC services using registered codecs. // RPCRegistry serves registered RPC services using registered codecs.

View File

@ -1,4 +1,4 @@
package rpc package registry
import ( import (
"fmt" "fmt"

View File

@ -6,12 +6,13 @@ import (
"git.loafle.net/commons_go/logging" "git.loafle.net/commons_go/logging"
"git.loafle.net/commons_go/rpc" "git.loafle.net/commons_go/rpc"
"git.loafle.net/commons_go/rpc/protocol" "git.loafle.net/commons_go/rpc/protocol"
"git.loafle.net/commons_go/rpc/registry"
) )
type ServletHandlers struct { type ServletHandlers struct {
rpc.ServletHandlers rpc.ServletHandlers
RPCRegistry rpc.Registry RPCRegistry registry.RPCRegistry
} }
func (sh *ServletHandlers) Invoke(servletCTX rpc.ServletContext, requestCodec protocol.RegistryCodec) (result interface{}, err error) { func (sh *ServletHandlers) Invoke(servletCTX rpc.ServletContext, requestCodec protocol.RegistryCodec) (result interface{}, err error) {

View File

@ -70,9 +70,9 @@ func (s *rpcServlet) Start(parentCTX cuc.Context, conn interface{}, doneChan cha
if err := s.sh.Init(s.ctx); nil != err { if err := s.sh.Init(s.ctx); nil != err {
logging.Logger().Panic(fmt.Sprintf("Servlet: Initialization of servlet has been failed %v", 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.stopChan = make(chan struct{})
s.responseQueueChan = make(chan *responseState, s.sh.GetPendingResponses())
s.stopWg.Add(1) s.stopWg.Add(1)
go handleServlet(s) go handleServlet(s)

View File

@ -30,7 +30,7 @@ func (sh *ServletHandlers) Init(servletCTX ServletContext) error {
} }
func (sh *ServletHandlers) Invoke(servletCTX ServletContext, requestCodec protocol.RegistryCodec) (result interface{}, err 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) { func (sh *ServletHandlers) Destroy(servletCTX ServletContext) {