msg_pb ok
This commit is contained in:
parent
3136fc7945
commit
4e9a24ebaa
@ -3,11 +3,8 @@ package dtmsvr
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/yedf/dtm/dtmcli"
|
|
||||||
pb "github.com/yedf/dtm/dtmpb"
|
pb "github.com/yedf/dtm/dtmpb"
|
||||||
"google.golang.org/grpc"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// dtmServer is used to implement helloworld.GreeterServer.
|
// dtmServer is used to implement helloworld.GreeterServer.
|
||||||
@ -17,7 +14,6 @@ type dtmServer struct {
|
|||||||
|
|
||||||
func (s *dtmServer) Call(ctx context.Context, in *pb.DtmRequest) (*pb.DtmReply, error) {
|
func (s *dtmServer) Call(ctx context.Context, in *pb.DtmRequest) (*pb.DtmReply, error) {
|
||||||
log.Printf("dtmServer Received: %v", in)
|
log.Printf("dtmServer Received: %v", in)
|
||||||
dynamicCallPb(ctx, in, in.Extra["BusiFunc"], []byte(in.Data))
|
|
||||||
return &pb.DtmReply{DtmResult: "SUCCESS", DtmMessage: "ok"}, nil
|
return &pb.DtmReply{DtmResult: "SUCCESS", DtmMessage: "ok"}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,15 +21,3 @@ func (s *dtmServer) Submit(ctx context.Context, in *pb.DtmRequest) (*pb.DtmReply
|
|||||||
svcSubmit(TransFromDtmRequest(in), in.WaitResult)
|
svcSubmit(TransFromDtmRequest(in), in.WaitResult)
|
||||||
return &pb.DtmReply{DtmResult: "SUCCESS", DtmMessage: "ok"}, nil
|
return &pb.DtmReply{DtmResult: "SUCCESS", DtmMessage: "ok"}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func dynamicCallPb(ctx context.Context, in *pb.DtmRequest, pbAddr string, data []byte) error {
|
|
||||||
fs := strings.Split(pbAddr, "/")
|
|
||||||
grpcAddr := fs[0]
|
|
||||||
method := "/" + strings.Join(fs[1:], "/")
|
|
||||||
conn, err := grpc.Dial(grpcAddr, grpc.WithInsecure(), grpc.WithBlock(), grpc.WithUnaryInterceptor(dtmcli.GrpcClientLog))
|
|
||||||
dtmcli.FatalIfError(err)
|
|
||||||
reply := &pb.BusiReply{}
|
|
||||||
err = conn.Invoke(ctx, method, &pb.BusiRequest{Info: &pb.DtmTransInfo{Gid: in.Gid}}, reply)
|
|
||||||
dtmcli.FatalIfError(err)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|||||||
@ -167,6 +167,7 @@ func (t *TransGlobal) getBranchResult(branch *TransBranch) string {
|
|||||||
BranchID: branch.BranchID,
|
BranchID: branch.BranchID,
|
||||||
BranchType: branch.BranchType,
|
BranchType: branch.BranchType,
|
||||||
},
|
},
|
||||||
|
AppData: []byte(branch.Data),
|
||||||
}, &reply)
|
}, &reply)
|
||||||
e2p(err)
|
e2p(err)
|
||||||
return reply.DtmResult
|
return reply.DtmResult
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user