diff --git a/dtmcli/msg_grpc.go b/dtmcli/msg_grpc.go new file mode 100644 index 0000000..b8a8902 --- /dev/null +++ b/dtmcli/msg_grpc.go @@ -0,0 +1,49 @@ +package dtmcli + +// MsgGrpc reliable msg type +type MsgGrpc struct { + MsgDataGrpc + TransBase +} + +// MsgDataGrpc msg data +type MsgDataGrpc struct { + TransData + Steps []MsgStepGrpc `json:"steps"` + QueryPrepared string `json:"query_prepared"` +} + +// MsgStepGrpc struct of one step msg +type MsgStepGrpc struct { + Action string `json:"action"` + Data string `json:"data"` +} + +// NewMsgGrpc create new msg +func NewMsgGrpc(server string, gid string) *MsgGrpc { + return &MsgGrpc{ + MsgDataGrpc: MsgDataGrpc{TransData: TransData{ + Gid: gid, + TransType: "msg", + }}, + TransBase: TransBase{ + Dtm: server, + }, + } +} + +// Add add a new step +func (s *MsgGrpc) Add(action string, postData interface{}) *MsgGrpc { + Logf("msg %s Add %s %v", s.MsgDataGrpc.Gid, action, postData) + step := MsgStepGrpc{ + Action: action, + Data: MustMarshalString(postData), + } + s.Steps = append(s.Steps, step) + return s +} + +// Submit submit the msg +func (s *MsgGrpc) Submit() error { + return s.CallDtm(&s.MsgDataGrpc, "submit") +} diff --git a/examples/busi.pb.go b/examples/busi.pb.go new file mode 100644 index 0000000..b431eee --- /dev/null +++ b/examples/busi.pb.go @@ -0,0 +1,274 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.26.0 +// protoc v3.17.3 +// source: examples/busi.proto + +package examples + +import ( + dtmcli "github.com/yedf/dtm/dtmcli" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// The request message containing the user's name. +type BusiRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Info *dtmcli.DtmTransInfo `protobuf:"bytes,1,opt,name=info,proto3" json:"info,omitempty"` + Extra map[string]string `protobuf:"bytes,2,rep,name=Extra,proto3" json:"Extra,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + AppData []byte `protobuf:"bytes,3,opt,name=AppData,proto3" json:"AppData,omitempty"` +} + +func (x *BusiRequest) Reset() { + *x = BusiRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_examples_busi_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *BusiRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BusiRequest) ProtoMessage() {} + +func (x *BusiRequest) ProtoReflect() protoreflect.Message { + mi := &file_examples_busi_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use BusiRequest.ProtoReflect.Descriptor instead. +func (*BusiRequest) Descriptor() ([]byte, []int) { + return file_examples_busi_proto_rawDescGZIP(), []int{0} +} + +func (x *BusiRequest) GetInfo() *dtmcli.DtmTransInfo { + if x != nil { + return x.Info + } + return nil +} + +func (x *BusiRequest) GetExtra() map[string]string { + if x != nil { + return x.Extra + } + return nil +} + +func (x *BusiRequest) GetAppData() []byte { + if x != nil { + return x.AppData + } + return nil +} + +// The response message containing the greetings +type BusiReply struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + DtmResult string `protobuf:"bytes,1,opt,name=DtmResult,proto3" json:"DtmResult,omitempty"` + DtmMessage string `protobuf:"bytes,2,opt,name=DtmMessage,proto3" json:"DtmMessage,omitempty"` +} + +func (x *BusiReply) Reset() { + *x = BusiReply{} + if protoimpl.UnsafeEnabled { + mi := &file_examples_busi_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *BusiReply) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BusiReply) ProtoMessage() {} + +func (x *BusiReply) ProtoReflect() protoreflect.Message { + mi := &file_examples_busi_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use BusiReply.ProtoReflect.Descriptor instead. +func (*BusiReply) Descriptor() ([]byte, []int) { + return file_examples_busi_proto_rawDescGZIP(), []int{1} +} + +func (x *BusiReply) GetDtmResult() string { + if x != nil { + return x.DtmResult + } + return "" +} + +func (x *BusiReply) GetDtmMessage() string { + if x != nil { + return x.DtmMessage + } + return "" +} + +var File_examples_busi_proto protoreflect.FileDescriptor + +var file_examples_busi_proto_rawDesc = []byte{ + 0x0a, 0x13, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x62, 0x75, 0x73, 0x69, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x1a, + 0x13, 0x64, 0x74, 0x6d, 0x63, 0x6c, 0x69, 0x2f, 0x64, 0x74, 0x6d, 0x63, 0x6c, 0x69, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xc3, 0x01, 0x0a, 0x0b, 0x42, 0x75, 0x73, 0x69, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x28, 0x0a, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x64, 0x74, 0x6d, 0x63, 0x6c, 0x69, 0x2e, 0x44, 0x74, 0x6d, 0x54, + 0x72, 0x61, 0x6e, 0x73, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x12, 0x36, + 0x0a, 0x05, 0x45, 0x78, 0x74, 0x72, 0x61, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, + 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x42, 0x75, 0x73, 0x69, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x2e, 0x45, 0x78, 0x74, 0x72, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, + 0x05, 0x45, 0x78, 0x74, 0x72, 0x61, 0x12, 0x18, 0x0a, 0x07, 0x41, 0x70, 0x70, 0x44, 0x61, 0x74, + 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x41, 0x70, 0x70, 0x44, 0x61, 0x74, 0x61, + 0x1a, 0x38, 0x0a, 0x0a, 0x45, 0x78, 0x74, 0x72, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, + 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, + 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x49, 0x0a, 0x09, 0x42, 0x75, + 0x73, 0x69, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x44, 0x74, 0x6d, 0x52, 0x65, + 0x73, 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x44, 0x74, 0x6d, 0x52, + 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x44, 0x74, 0x6d, 0x4d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x44, 0x74, 0x6d, 0x4d, 0x65, + 0x73, 0x73, 0x61, 0x67, 0x65, 0x32, 0xf8, 0x01, 0x0a, 0x04, 0x42, 0x75, 0x73, 0x69, 0x12, 0x37, + 0x0a, 0x07, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x49, 0x6e, 0x12, 0x15, 0x2e, 0x65, 0x78, 0x61, 0x6d, + 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x42, 0x75, 0x73, 0x69, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x13, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x42, 0x75, 0x73, 0x69, + 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x38, 0x0a, 0x08, 0x54, 0x72, 0x61, 0x6e, 0x73, + 0x4f, 0x75, 0x74, 0x12, 0x15, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x42, + 0x75, 0x73, 0x69, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x65, 0x78, 0x61, + 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x42, 0x75, 0x73, 0x69, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, + 0x00, 0x12, 0x3d, 0x0a, 0x0d, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x49, 0x6e, 0x52, 0x65, 0x76, 0x65, + 0x72, 0x74, 0x12, 0x15, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x42, 0x75, + 0x73, 0x69, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x65, 0x78, 0x61, 0x6d, + 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x42, 0x75, 0x73, 0x69, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, + 0x12, 0x3e, 0x0a, 0x0e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x4f, 0x75, 0x74, 0x52, 0x65, 0x76, 0x65, + 0x72, 0x74, 0x12, 0x15, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x42, 0x75, + 0x73, 0x69, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x65, 0x78, 0x61, 0x6d, + 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x42, 0x75, 0x73, 0x69, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, + 0x42, 0x1e, 0x5a, 0x1c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x79, + 0x65, 0x64, 0x66, 0x2f, 0x64, 0x74, 0x6d, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_examples_busi_proto_rawDescOnce sync.Once + file_examples_busi_proto_rawDescData = file_examples_busi_proto_rawDesc +) + +func file_examples_busi_proto_rawDescGZIP() []byte { + file_examples_busi_proto_rawDescOnce.Do(func() { + file_examples_busi_proto_rawDescData = protoimpl.X.CompressGZIP(file_examples_busi_proto_rawDescData) + }) + return file_examples_busi_proto_rawDescData +} + +var file_examples_busi_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_examples_busi_proto_goTypes = []interface{}{ + (*BusiRequest)(nil), // 0: examples.BusiRequest + (*BusiReply)(nil), // 1: examples.BusiReply + nil, // 2: examples.BusiRequest.ExtraEntry + (*dtmcli.DtmTransInfo)(nil), // 3: dtmcli.DtmTransInfo +} +var file_examples_busi_proto_depIdxs = []int32{ + 3, // 0: examples.BusiRequest.info:type_name -> dtmcli.DtmTransInfo + 2, // 1: examples.BusiRequest.Extra:type_name -> examples.BusiRequest.ExtraEntry + 0, // 2: examples.Busi.TransIn:input_type -> examples.BusiRequest + 0, // 3: examples.Busi.TransOut:input_type -> examples.BusiRequest + 0, // 4: examples.Busi.TransInRevert:input_type -> examples.BusiRequest + 0, // 5: examples.Busi.TransOutRevert:input_type -> examples.BusiRequest + 1, // 6: examples.Busi.TransIn:output_type -> examples.BusiReply + 1, // 7: examples.Busi.TransOut:output_type -> examples.BusiReply + 1, // 8: examples.Busi.TransInRevert:output_type -> examples.BusiReply + 1, // 9: examples.Busi.TransOutRevert:output_type -> examples.BusiReply + 6, // [6:10] is the sub-list for method output_type + 2, // [2:6] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name +} + +func init() { file_examples_busi_proto_init() } +func file_examples_busi_proto_init() { + if File_examples_busi_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_examples_busi_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*BusiRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_examples_busi_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*BusiReply); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_examples_busi_proto_rawDesc, + NumEnums: 0, + NumMessages: 3, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_examples_busi_proto_goTypes, + DependencyIndexes: file_examples_busi_proto_depIdxs, + MessageInfos: file_examples_busi_proto_msgTypes, + }.Build() + File_examples_busi_proto = out.File + file_examples_busi_proto_rawDesc = nil + file_examples_busi_proto_goTypes = nil + file_examples_busi_proto_depIdxs = nil +} diff --git a/examples/busi.proto b/examples/busi.proto new file mode 100644 index 0000000..d6816b6 --- /dev/null +++ b/examples/busi.proto @@ -0,0 +1,27 @@ +syntax = "proto3"; + +package examples; + +option go_package = "github.com/yedf/dtm/examples"; +import "dtmcli/dtmcli.proto"; + +// The dtm service definition. +service Busi { + rpc TransIn(BusiRequest) returns (BusiReply) {} + rpc TransOut(BusiRequest) returns (BusiReply) {} + rpc TransInRevert(BusiRequest) returns (BusiReply) {} + rpc TransOutRevert(BusiRequest) returns (BusiReply) {} +} + +// The request message containing the user's name. +message BusiRequest { + dtmcli.DtmTransInfo info = 1; + map Extra = 2; + bytes AppData = 3; +} + +// The response message containing the greetings +message BusiReply { + string DtmResult = 1; + string DtmMessage = 2; +} \ No newline at end of file diff --git a/examples/busi_grpc.pb.go b/examples/busi_grpc.pb.go new file mode 100644 index 0000000..524c697 --- /dev/null +++ b/examples/busi_grpc.pb.go @@ -0,0 +1,209 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. + +package examples + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +// BusiClient is the client API for Busi service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type BusiClient interface { + TransIn(ctx context.Context, in *BusiRequest, opts ...grpc.CallOption) (*BusiReply, error) + TransOut(ctx context.Context, in *BusiRequest, opts ...grpc.CallOption) (*BusiReply, error) + TransInRevert(ctx context.Context, in *BusiRequest, opts ...grpc.CallOption) (*BusiReply, error) + TransOutRevert(ctx context.Context, in *BusiRequest, opts ...grpc.CallOption) (*BusiReply, error) +} + +type busiClient struct { + cc grpc.ClientConnInterface +} + +func NewBusiClient(cc grpc.ClientConnInterface) BusiClient { + return &busiClient{cc} +} + +func (c *busiClient) TransIn(ctx context.Context, in *BusiRequest, opts ...grpc.CallOption) (*BusiReply, error) { + out := new(BusiReply) + err := c.cc.Invoke(ctx, "/examples.Busi/TransIn", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *busiClient) TransOut(ctx context.Context, in *BusiRequest, opts ...grpc.CallOption) (*BusiReply, error) { + out := new(BusiReply) + err := c.cc.Invoke(ctx, "/examples.Busi/TransOut", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *busiClient) TransInRevert(ctx context.Context, in *BusiRequest, opts ...grpc.CallOption) (*BusiReply, error) { + out := new(BusiReply) + err := c.cc.Invoke(ctx, "/examples.Busi/TransInRevert", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *busiClient) TransOutRevert(ctx context.Context, in *BusiRequest, opts ...grpc.CallOption) (*BusiReply, error) { + out := new(BusiReply) + err := c.cc.Invoke(ctx, "/examples.Busi/TransOutRevert", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// BusiServer is the server API for Busi service. +// All implementations must embed UnimplementedBusiServer +// for forward compatibility +type BusiServer interface { + TransIn(context.Context, *BusiRequest) (*BusiReply, error) + TransOut(context.Context, *BusiRequest) (*BusiReply, error) + TransInRevert(context.Context, *BusiRequest) (*BusiReply, error) + TransOutRevert(context.Context, *BusiRequest) (*BusiReply, error) + mustEmbedUnimplementedBusiServer() +} + +// UnimplementedBusiServer must be embedded to have forward compatible implementations. +type UnimplementedBusiServer struct { +} + +func (UnimplementedBusiServer) TransIn(context.Context, *BusiRequest) (*BusiReply, error) { + return nil, status.Errorf(codes.Unimplemented, "method TransIn not implemented") +} +func (UnimplementedBusiServer) TransOut(context.Context, *BusiRequest) (*BusiReply, error) { + return nil, status.Errorf(codes.Unimplemented, "method TransOut not implemented") +} +func (UnimplementedBusiServer) TransInRevert(context.Context, *BusiRequest) (*BusiReply, error) { + return nil, status.Errorf(codes.Unimplemented, "method TransInRevert not implemented") +} +func (UnimplementedBusiServer) TransOutRevert(context.Context, *BusiRequest) (*BusiReply, error) { + return nil, status.Errorf(codes.Unimplemented, "method TransOutRevert not implemented") +} +func (UnimplementedBusiServer) mustEmbedUnimplementedBusiServer() {} + +// UnsafeBusiServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to BusiServer will +// result in compilation errors. +type UnsafeBusiServer interface { + mustEmbedUnimplementedBusiServer() +} + +func RegisterBusiServer(s grpc.ServiceRegistrar, srv BusiServer) { + s.RegisterService(&Busi_ServiceDesc, srv) +} + +func _Busi_TransIn_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(BusiRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(BusiServer).TransIn(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/examples.Busi/TransIn", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(BusiServer).TransIn(ctx, req.(*BusiRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Busi_TransOut_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(BusiRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(BusiServer).TransOut(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/examples.Busi/TransOut", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(BusiServer).TransOut(ctx, req.(*BusiRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Busi_TransInRevert_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(BusiRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(BusiServer).TransInRevert(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/examples.Busi/TransInRevert", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(BusiServer).TransInRevert(ctx, req.(*BusiRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Busi_TransOutRevert_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(BusiRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(BusiServer).TransOutRevert(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/examples.Busi/TransOutRevert", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(BusiServer).TransOutRevert(ctx, req.(*BusiRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// Busi_ServiceDesc is the grpc.ServiceDesc for Busi service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Busi_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "examples.Busi", + HandlerType: (*BusiServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "TransIn", + Handler: _Busi_TransIn_Handler, + }, + { + MethodName: "TransOut", + Handler: _Busi_TransOut_Handler, + }, + { + MethodName: "TransInRevert", + Handler: _Busi_TransInRevert_Handler, + }, + { + MethodName: "TransOutRevert", + Handler: _Busi_TransOutRevert_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "examples/busi.proto", +} diff --git a/examples/main_msg_pb.go b/examples/main_msg_pb.go new file mode 100644 index 0000000..292ef8c --- /dev/null +++ b/examples/main_msg_pb.go @@ -0,0 +1,21 @@ +package examples + +import ( + "context" + + "github.com/gin-gonic/gin" + "github.com/yedf/dtm/dtmcli" +) + +// MsgPbSetup 1 +func MsgPbSetup(app *gin.Engine) { + +} + +// MsgPbFireRequest 1 +func MsgPbFireRequest() string { + dtmcli.Logf("MsgPbFireRequest") + reply, err := DtmClient.Call(context.Background(), &dtmcli.DtmRequest{}) + dtmcli.Logf("reply and err is: %v, %v", reply, err) + return "" +}