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