ing
This commit is contained in:
parent
5f10acb5e9
commit
5b2b7c19e4
|
@ -24,6 +24,17 @@ type GatewayRPCServletHandlers struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sh *GatewayRPCServletHandlers) Invoke(servletCTX rpc.ServletContext, requestCodec protocol.RegistryCodec) (result interface{}, err error) {
|
func (sh *GatewayRPCServletHandlers) Invoke(servletCTX rpc.ServletContext, requestCodec protocol.RegistryCodec) (result interface{}, err error) {
|
||||||
|
defer func () {
|
||||||
|
if nil != err {
|
||||||
|
logging.Logger().Errorf("Gateway Websocket: Inovke error %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !requestCodec.HasResponse() {
|
||||||
|
result = nil
|
||||||
|
err = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
md := servletCTX.GetAttribute(oogw.GRPCMetadataKey)
|
md := servletCTX.GetAttribute(oogw.GRPCMetadataKey)
|
||||||
if nil == md {
|
if nil == md {
|
||||||
md = metadata.Pairs(
|
md = metadata.Pairs(
|
||||||
|
@ -36,23 +47,31 @@ func (sh *GatewayRPCServletHandlers) Invoke(servletCTX rpc.ServletContext, reque
|
||||||
|
|
||||||
grpcCTX := metadata.NewOutgoingContext(context.Background(), md.(metadata.MD))
|
grpcCTX := metadata.NewOutgoingContext(context.Background(), md.(metadata.MD))
|
||||||
|
|
||||||
params, err := requestCodec.Params()
|
var (
|
||||||
|
grpcResult string
|
||||||
|
params []string
|
||||||
|
)
|
||||||
|
|
||||||
|
params, err = requestCodec.Params()
|
||||||
if nil != err {
|
if nil != err {
|
||||||
return nil, err
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
r, err := grpc.Exec(grpcCTX, requestCodec.Method(), params)
|
grpcResult, err = grpc.Exec(grpcCTX, requestCodec.Method(), params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var m interface{}
|
if !requestCodec.HasResponse() {
|
||||||
err = json.Unmarshal([]byte(r), &m)
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal([]byte(grpcResult), &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
return m, nil
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sh *GatewayRPCServletHandlers) Validate() {
|
func (sh *GatewayRPCServletHandlers) Validate() {
|
||||||
|
|
|
@ -70,8 +70,6 @@ func (sh *RPCGatewayServletHandlers) Handle(soc cwf.Socket, stopChan <-chan stru
|
||||||
var err error
|
var err error
|
||||||
rpcServlet := retainRPCServlet(sh.gwRPCSH, sh.rpcRWCSH)
|
rpcServlet := retainRPCServlet(sh.gwRPCSH, sh.rpcRWCSH)
|
||||||
|
|
||||||
// rpcServlet := cRPC.NewServlet(sh.gwRPCSH, sh.rpcRWCSH)
|
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
rpcServlet.Stop()
|
rpcServlet.Stop()
|
||||||
releaseRPCServlet(rpcServlet)
|
releaseRPCServlet(rpcServlet)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user