chore: 并入 iotlcm-upstream-proxy 历史到 upstream-proxy/(原提交 44209ec)
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
package msgcallpb
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.5iot.com/iotlcm-public/iotlcm-upstream-proxy/internal/pb"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-upstream-proxy/internal/pub/xjpubservice"
|
||||
"github.com/gogf/gf/contrib/rpc/grpcx/v2"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
type Controller struct {
|
||||
pb.UnimplementedMsgCallServer
|
||||
}
|
||||
|
||||
func Register(s *grpcx.GrpcServer) {
|
||||
pb.RegisterMsgCallServer(s.Server, &Controller{})
|
||||
}
|
||||
|
||||
func (c *Controller) OneCall(ctx context.Context, req *pb.MsgReq) (res *pb.MsgRes, err error) {
|
||||
res = &pb.MsgRes{
|
||||
Head: &pb.HeadRes{
|
||||
Code: -1,
|
||||
Message: "service not found",
|
||||
},
|
||||
Service: req.Service,
|
||||
Method: req.Method,
|
||||
}
|
||||
if req.Head != nil {
|
||||
res.Head.RouterId = req.Head.RouterId
|
||||
res.Head.TraceId = req.Head.TraceId
|
||||
}
|
||||
|
||||
info := xjpubservice.InfoRpc().GetInfo()
|
||||
if req.Service != info.Name {
|
||||
g.Log().Errorf(ctx, "OneCall Service not found: service: %s, info: %s", req.Service, info.Name)
|
||||
return res, nil
|
||||
}
|
||||
{
|
||||
g.Log().Errorf(ctx, "OneCall Method not found: method: %s", req.Method)
|
||||
res.Head.Code = -1
|
||||
res.Head.Message = "method not found"
|
||||
return res, nil
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
Reference in New Issue
Block a user