ing
This commit is contained in:
parent
9c024a9f88
commit
28a86a9282
|
@ -11,6 +11,7 @@ import (
|
||||||
og "git.loafle.net/overflow/gateway"
|
og "git.loafle.net/overflow/gateway"
|
||||||
ogeg "git.loafle.net/overflow/gateway/external/grpc"
|
ogeg "git.loafle.net/overflow/gateway/external/grpc"
|
||||||
"github.com/valyala/fasthttp"
|
"github.com/valyala/fasthttp"
|
||||||
|
"google.golang.org/grpc/metadata"
|
||||||
)
|
)
|
||||||
|
|
||||||
type RPCServlet interface {
|
type RPCServlet interface {
|
||||||
|
@ -41,11 +42,8 @@ func (s *RPCServlets) Handle(servletCtx server.ServletCtx,
|
||||||
doneChan <- struct{}{}
|
doneChan <- struct{}{}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
sc := crpj.NewServerCodec()
|
|
||||||
|
|
||||||
servletCtx.SetAttribute(og.SessionWriteChanKey, writeChan)
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
md metadata.MD
|
||||||
src crp.ServerRequestCodec
|
src crp.ServerRequestCodec
|
||||||
method string
|
method string
|
||||||
params []string
|
params []string
|
||||||
|
@ -54,6 +52,21 @@ func (s *RPCServlets) Handle(servletCtx server.ServletCtx,
|
||||||
replyBuff []byte
|
replyBuff []byte
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
sc := crpj.NewServerCodec()
|
||||||
|
|
||||||
|
_clientType := servletCtx.GetAttribute(og.SessionClientTypeKey)
|
||||||
|
_sessionID := servletCtx.GetAttribute(og.SessionIDKey)
|
||||||
|
_targetID := servletCtx.GetAttribute(og.SessionTargetIDKey)
|
||||||
|
|
||||||
|
if nil != _clientType && nil != _sessionID && nil != _targetID {
|
||||||
|
md = metadata.Pairs(
|
||||||
|
og.GRPCClientTypeKey, _clientType.(og.ClientType).String(),
|
||||||
|
og.GRPCSessionIDKey, _sessionID.(string),
|
||||||
|
og.GRPCTargetIDKey, _targetID.(string),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
servletCtx.SetAttribute(og.SessionWriteChanKey, writeChan)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
|
@ -76,7 +89,7 @@ func (s *RPCServlets) Handle(servletCtx server.ServletCtx,
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
grpcCtx = context.Background()
|
grpcCtx = metadata.NewOutgoingContext(context.Background(), md)
|
||||||
grpcReply, err = ogeg.Exec(grpcCtx, method, params...)
|
grpcReply, err = ogeg.Exec(grpcCtx, method, params...)
|
||||||
replyBuff, err = src.NewResponseWithString(grpcReply, err)
|
replyBuff, err = src.NewResponseWithString(grpcReply, err)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user