ing
This commit is contained in:
parent
38b336e1bb
commit
8b1a5e3c74
|
@ -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")
|
||||||
|
}
|
||||||
|
|
|
@ -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.
|
|
@ -1,4 +1,4 @@
|
||||||
package rpc
|
package registry
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
|
@ -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) {
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user