package msgcallpb import ( "context" "git.5iot.com/iotlcm-public/iotlcm-upstream-chan/internal/pb" "git.5iot.com/iotlcm-public/iotlcm-upstream-chan/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 }