Browse Source

more code from dtmcli

pull/25/head
yedf2 5 years ago
parent
commit
74813607a3
  1. 145
      dtmpb/dtmpb.pb.go
  2. 8
      dtmpb/dtmpb.proto
  3. 53
      dtmpb/dtmpb_grpc.pb.go
  4. 20
      dtmpb/message.go
  5. 11
      dtmsvr/api_grpc.go
  6. 14
      dtmsvr/trans.go
  7. 69
      examples/busi.pb.go
  8. 11
      examples/busi.proto
  9. 77
      examples/busi_grpc.pb.go
  10. 14
      examples/main_grpc.go

145
dtmpb/dtmpb.pb.go

@ -9,6 +9,7 @@ package dtmpb
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
emptypb "google.golang.org/protobuf/types/known/emptypb"
reflect "reflect"
sync "sync"
)
@ -367,63 +368,62 @@ var File_dtmpb_dtmpb_proto protoreflect.FileDescriptor
var file_dtmpb_dtmpb_proto_rawDesc = []byte{
0x0a, 0x11, 0x64, 0x74, 0x6d, 0x70, 0x62, 0x2f, 0x64, 0x74, 0x6d, 0x70, 0x62, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x12, 0x06, 0x64, 0x74, 0x6d, 0x63, 0x6c, 0x69, 0x22, 0x8c, 0x01, 0x0a, 0x0c,
0x44, 0x74, 0x6d, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x10, 0x0a, 0x03,
0x47, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x47, 0x69, 0x64, 0x12, 0x1c,
0x0a, 0x09, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x54, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
0x09, 0x52, 0x09, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x08,
0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x49, 0x44, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08,
0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x49, 0x44, 0x12, 0x1e, 0x0a, 0x0a, 0x42, 0x72, 0x61, 0x6e,
0x63, 0x68, 0x54, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x42, 0x72,
0x61, 0x6e, 0x63, 0x68, 0x54, 0x79, 0x70, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x44, 0x74, 0x6d, 0x18,
0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x44, 0x74, 0x6d, 0x22, 0x85, 0x02, 0x0a, 0x0a, 0x44,
0x74, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x47, 0x69, 0x64,
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x47, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x54,
0x72, 0x61, 0x6e, 0x73, 0x54, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09,
0x54, 0x72, 0x61, 0x6e, 0x73, 0x54, 0x79, 0x70, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x51, 0x75, 0x65,
0x72, 0x79, 0x50, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09,
0x52, 0x0d, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x64, 0x12,
0x1e, 0x0a, 0x0a, 0x57, 0x61, 0x69, 0x74, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x04, 0x20,
0x01, 0x28, 0x08, 0x52, 0x0a, 0x57, 0x61, 0x69, 0x74, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12,
0x33, 0x0a, 0x05, 0x45, 0x78, 0x74, 0x72, 0x61, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d,
0x2e, 0x64, 0x74, 0x6d, 0x63, 0x6c, 0x69, 0x2e, 0x44, 0x74, 0x6d, 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, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x06, 0x20, 0x01,
0x28, 0x09, 0x52, 0x04, 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, 0x48, 0x0a, 0x08, 0x44, 0x74, 0x6d, 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, 0x22, 0xc1, 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, 0x34, 0x0a, 0x05, 0x45, 0x78, 0x74, 0x72, 0x61, 0x18,
0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x64, 0x74, 0x6d, 0x63, 0x6c, 0x69, 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, 0x67, 0x0a, 0x03, 0x44,
0x74, 0x6d, 0x12, 0x2e, 0x0a, 0x04, 0x43, 0x61, 0x6c, 0x6c, 0x12, 0x12, 0x2e, 0x64, 0x74, 0x6d,
0x63, 0x6c, 0x69, 0x2e, 0x44, 0x74, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x10,
0x2e, 0x64, 0x74, 0x6d, 0x63, 0x6c, 0x69, 0x2e, 0x44, 0x74, 0x6d, 0x52, 0x65, 0x70, 0x6c, 0x79,
0x22, 0x00, 0x12, 0x30, 0x0a, 0x06, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x12, 0x12, 0x2e, 0x64,
0x74, 0x6d, 0x63, 0x6c, 0x69, 0x2e, 0x44, 0x74, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x1a, 0x10, 0x2e, 0x64, 0x74, 0x6d, 0x63, 0x6c, 0x69, 0x2e, 0x44, 0x74, 0x6d, 0x52, 0x65, 0x70,
0x6c, 0x79, 0x22, 0x00, 0x42, 0x1b, 0x5a, 0x19, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63,
0x6f, 0x6d, 0x2f, 0x79, 0x65, 0x64, 0x66, 0x2f, 0x64, 0x74, 0x6d, 0x2f, 0x64, 0x74, 0x6d, 0x70,
0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x6f, 0x74, 0x6f, 0x12, 0x05, 0x64, 0x74, 0x6d, 0x70, 0x62, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67,
0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74,
0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x8c, 0x01, 0x0a, 0x0c, 0x44, 0x74, 0x6d, 0x54,
0x72, 0x61, 0x6e, 0x73, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x10, 0x0a, 0x03, 0x47, 0x69, 0x64, 0x18,
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x47, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x54, 0x72,
0x61, 0x6e, 0x73, 0x54, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x54,
0x72, 0x61, 0x6e, 0x73, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x42, 0x72, 0x61, 0x6e,
0x63, 0x68, 0x49, 0x44, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x42, 0x72, 0x61, 0x6e,
0x63, 0x68, 0x49, 0x44, 0x12, 0x1e, 0x0a, 0x0a, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x54, 0x79,
0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68,
0x54, 0x79, 0x70, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x44, 0x74, 0x6d, 0x18, 0x05, 0x20, 0x01, 0x28,
0x09, 0x52, 0x03, 0x44, 0x74, 0x6d, 0x22, 0x84, 0x02, 0x0a, 0x0a, 0x44, 0x74, 0x6d, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x47, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01,
0x28, 0x09, 0x52, 0x03, 0x47, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x54, 0x72, 0x61, 0x6e, 0x73,
0x54, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x54, 0x72, 0x61, 0x6e,
0x73, 0x54, 0x79, 0x70, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72,
0x65, 0x70, 0x61, 0x72, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x51, 0x75,
0x65, 0x72, 0x79, 0x50, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x57,
0x61, 0x69, 0x74, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52,
0x0a, 0x57, 0x61, 0x69, 0x74, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x32, 0x0a, 0x05, 0x45,
0x78, 0x74, 0x72, 0x61, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x64, 0x74, 0x6d,
0x70, 0x62, 0x2e, 0x44, 0x74, 0x6d, 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,
0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 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, 0x48, 0x0a,
0x08, 0x44, 0x74, 0x6d, 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, 0x22, 0xbf, 0x01, 0x0a, 0x0b, 0x42, 0x75, 0x73, 0x69,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x27, 0x0a, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x18,
0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x64, 0x74, 0x6d, 0x70, 0x62, 0x2e, 0x44, 0x74,
0x6d, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x69, 0x6e, 0x66, 0x6f,
0x12, 0x33, 0x0a, 0x05, 0x45, 0x78, 0x74, 0x72, 0x61, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32,
0x1d, 0x2e, 0x64, 0x74, 0x6d, 0x70, 0x62, 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, 0x3c, 0x0a, 0x03, 0x44, 0x74, 0x6d, 0x12, 0x35, 0x0a, 0x06, 0x53,
0x75, 0x62, 0x6d, 0x69, 0x74, 0x12, 0x11, 0x2e, 0x64, 0x74, 0x6d, 0x70, 0x62, 0x2e, 0x44, 0x74,
0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c,
0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79,
0x22, 0x00, 0x42, 0x1b, 0x5a, 0x19, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d,
0x2f, 0x79, 0x65, 0x64, 0x66, 0x2f, 0x64, 0x74, 0x6d, 0x2f, 0x64, 0x74, 0x6d, 0x70, 0x62, 0x62,
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@ -440,24 +440,23 @@ func file_dtmpb_dtmpb_proto_rawDescGZIP() []byte {
var file_dtmpb_dtmpb_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
var file_dtmpb_dtmpb_proto_goTypes = []interface{}{
(*DtmTransInfo)(nil), // 0: dtmcli.DtmTransInfo
(*DtmRequest)(nil), // 1: dtmcli.DtmRequest
(*DtmReply)(nil), // 2: dtmcli.DtmReply
(*BusiRequest)(nil), // 3: dtmcli.BusiRequest
(*BusiReply)(nil), // 4: dtmcli.BusiReply
nil, // 5: dtmcli.DtmRequest.ExtraEntry
nil, // 6: dtmcli.BusiRequest.ExtraEntry
(*DtmTransInfo)(nil), // 0: dtmpb.DtmTransInfo
(*DtmRequest)(nil), // 1: dtmpb.DtmRequest
(*DtmReply)(nil), // 2: dtmpb.DtmReply
(*BusiRequest)(nil), // 3: dtmpb.BusiRequest
(*BusiReply)(nil), // 4: dtmpb.BusiReply
nil, // 5: dtmpb.DtmRequest.ExtraEntry
nil, // 6: dtmpb.BusiRequest.ExtraEntry
(*emptypb.Empty)(nil), // 7: google.protobuf.Empty
}
var file_dtmpb_dtmpb_proto_depIdxs = []int32{
5, // 0: dtmcli.DtmRequest.Extra:type_name -> dtmcli.DtmRequest.ExtraEntry
0, // 1: dtmcli.BusiRequest.info:type_name -> dtmcli.DtmTransInfo
6, // 2: dtmcli.BusiRequest.Extra:type_name -> dtmcli.BusiRequest.ExtraEntry
1, // 3: dtmcli.Dtm.Call:input_type -> dtmcli.DtmRequest
1, // 4: dtmcli.Dtm.Submit:input_type -> dtmcli.DtmRequest
2, // 5: dtmcli.Dtm.Call:output_type -> dtmcli.DtmReply
2, // 6: dtmcli.Dtm.Submit:output_type -> dtmcli.DtmReply
5, // [5:7] is the sub-list for method output_type
3, // [3:5] is the sub-list for method input_type
5, // 0: dtmpb.DtmRequest.Extra:type_name -> dtmpb.DtmRequest.ExtraEntry
0, // 1: dtmpb.BusiRequest.info:type_name -> dtmpb.DtmTransInfo
6, // 2: dtmpb.BusiRequest.Extra:type_name -> dtmpb.BusiRequest.ExtraEntry
1, // 3: dtmpb.Dtm.Submit:input_type -> dtmpb.DtmRequest
7, // 4: dtmpb.Dtm.Submit:output_type -> google.protobuf.Empty
4, // [4:5] is the sub-list for method output_type
3, // [3:4] is the sub-list for method input_type
3, // [3:3] is the sub-list for extension type_name
3, // [3:3] is the sub-list for extension extendee
0, // [0:3] is the sub-list for field type_name

8
dtmpb/dtmpb.proto

@ -1,13 +1,13 @@
syntax = "proto3";
option go_package = "github.com/yedf/dtm/dtmpb";
import "google/protobuf/empty.proto";
package dtmcli;
package dtmpb;
// The dtm service definition.
service Dtm {
rpc Call(DtmRequest) returns (DtmReply) {}
rpc Submit(DtmRequest) returns (DtmReply) {}
rpc Submit(DtmRequest) returns (google.protobuf.Empty) {}
}
@ -37,7 +37,7 @@ message DtmReply {
// The request message containing the user's name.
message BusiRequest {
dtmcli.DtmTransInfo info = 1;
DtmTransInfo info = 1;
map<string, string> Extra = 2;
bytes AppData = 3;
}

53
dtmpb/dtmpb_grpc.pb.go

@ -7,6 +7,7 @@ import (
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
emptypb "google.golang.org/protobuf/types/known/emptypb"
)
// This is a compile-time assertion to ensure that this generated file
@ -18,8 +19,7 @@ const _ = grpc.SupportPackageIsVersion7
//
// 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 DtmClient interface {
Call(ctx context.Context, in *DtmRequest, opts ...grpc.CallOption) (*DtmReply, error)
Submit(ctx context.Context, in *DtmRequest, opts ...grpc.CallOption) (*DtmReply, error)
Submit(ctx context.Context, in *DtmRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
}
type dtmClient struct {
@ -30,18 +30,9 @@ func NewDtmClient(cc grpc.ClientConnInterface) DtmClient {
return &dtmClient{cc}
}
func (c *dtmClient) Call(ctx context.Context, in *DtmRequest, opts ...grpc.CallOption) (*DtmReply, error) {
out := new(DtmReply)
err := c.cc.Invoke(ctx, "/dtmcli.Dtm/Call", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *dtmClient) Submit(ctx context.Context, in *DtmRequest, opts ...grpc.CallOption) (*DtmReply, error) {
out := new(DtmReply)
err := c.cc.Invoke(ctx, "/dtmcli.Dtm/Submit", in, out, opts...)
func (c *dtmClient) Submit(ctx context.Context, in *DtmRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
out := new(emptypb.Empty)
err := c.cc.Invoke(ctx, "/dtmpb.Dtm/Submit", in, out, opts...)
if err != nil {
return nil, err
}
@ -52,8 +43,7 @@ func (c *dtmClient) Submit(ctx context.Context, in *DtmRequest, opts ...grpc.Cal
// All implementations must embed UnimplementedDtmServer
// for forward compatibility
type DtmServer interface {
Call(context.Context, *DtmRequest) (*DtmReply, error)
Submit(context.Context, *DtmRequest) (*DtmReply, error)
Submit(context.Context, *DtmRequest) (*emptypb.Empty, error)
mustEmbedUnimplementedDtmServer()
}
@ -61,10 +51,7 @@ type DtmServer interface {
type UnimplementedDtmServer struct {
}
func (UnimplementedDtmServer) Call(context.Context, *DtmRequest) (*DtmReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method Call not implemented")
}
func (UnimplementedDtmServer) Submit(context.Context, *DtmRequest) (*DtmReply, error) {
func (UnimplementedDtmServer) Submit(context.Context, *DtmRequest) (*emptypb.Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method Submit not implemented")
}
func (UnimplementedDtmServer) mustEmbedUnimplementedDtmServer() {}
@ -80,24 +67,6 @@ func RegisterDtmServer(s grpc.ServiceRegistrar, srv DtmServer) {
s.RegisterService(&Dtm_ServiceDesc, srv)
}
func _Dtm_Call_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(DtmRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(DtmServer).Call(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/dtmcli.Dtm/Call",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(DtmServer).Call(ctx, req.(*DtmRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Dtm_Submit_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(DtmRequest)
if err := dec(in); err != nil {
@ -108,7 +77,7 @@ func _Dtm_Submit_Handler(srv interface{}, ctx context.Context, dec func(interfac
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/dtmcli.Dtm/Submit",
FullMethod: "/dtmpb.Dtm/Submit",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(DtmServer).Submit(ctx, req.(*DtmRequest))
@ -120,13 +89,9 @@ func _Dtm_Submit_Handler(srv interface{}, ctx context.Context, dec func(interfac
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Dtm_ServiceDesc = grpc.ServiceDesc{
ServiceName: "dtmcli.Dtm",
ServiceName: "dtmpb.Dtm",
HandlerType: (*DtmServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Call",
Handler: _Dtm_Call_Handler,
},
{
MethodName: "Submit",
Handler: _Dtm_Submit_Handler,

20
dtmpb/message.go

@ -8,27 +8,14 @@ import (
// MsgGrpc reliable msg type
type MsgGrpc struct {
MsgDataGrpc
dtmcli.MsgData
dtmcli.TransBase
}
// MsgDataGrpc msg data
type MsgDataGrpc struct {
dtmcli.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: dtmcli.TransData{
MsgData: dtmcli.MsgData{TransData: dtmcli.TransData{
Gid: gid,
TransType: "msg",
}},
@ -40,8 +27,7 @@ func NewMsgGrpc(server string, gid string) *MsgGrpc {
// Add add a new step
func (s *MsgGrpc) Add(action string, data []byte) *MsgGrpc {
dtmcli.Logf("msg %s Add %s %v", s.MsgDataGrpc.Gid, action, string(data))
step := MsgStepGrpc{
step := dtmcli.MsgStep{
Action: action,
Data: string(data),
}

11
dtmsvr/api_grpc.go

@ -2,9 +2,9 @@ package dtmsvr
import (
"context"
"log"
pb "github.com/yedf/dtm/dtmpb"
"google.golang.org/protobuf/types/known/emptypb"
)
// dtmServer is used to implement helloworld.GreeterServer.
@ -12,12 +12,7 @@ type dtmServer struct {
pb.UnimplementedDtmServer
}
func (s *dtmServer) Call(ctx context.Context, in *pb.DtmRequest) (*pb.DtmReply, error) {
log.Printf("dtmServer Received: %v", in)
return &pb.DtmReply{DtmResult: "SUCCESS", DtmMessage: "ok"}, nil
}
func (s *dtmServer) Submit(ctx context.Context, in *pb.DtmRequest) (*pb.DtmReply, error) {
func (s *dtmServer) Submit(ctx context.Context, in *pb.DtmRequest) (*emptypb.Empty, error) {
svcSubmit(TransFromDtmRequest(in), in.WaitResult)
return &pb.DtmReply{DtmResult: "SUCCESS", DtmMessage: "ok"}, nil
return &emptypb.Empty{}, nil
}

14
dtmsvr/trans.go

@ -10,6 +10,9 @@ import (
"github.com/yedf/dtm/common"
"github.com/yedf/dtm/dtmcli"
"github.com/yedf/dtm/dtmpb"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/emptypb"
"gorm.io/gorm"
"gorm.io/gorm/clause"
)
@ -159,7 +162,6 @@ func (t *TransGlobal) getBranchResult(branch *TransBranch) string {
if t.Protocol == "grpc" {
server, method := dtmpb.GetServerAndMethod(branch.URL)
conn := dtmpb.MustGetGrpcConn(server)
reply := dtmpb.BusiReply{}
err := conn.Invoke(context.Background(), method, &dtmpb.BusiRequest{
Info: &dtmpb.DtmTransInfo{
Gid: t.Gid,
@ -168,9 +170,13 @@ func (t *TransGlobal) getBranchResult(branch *TransBranch) string {
BranchType: branch.BranchType,
},
AppData: []byte(branch.Data),
}, &reply)
e2p(err)
return reply.DtmResult
}, &emptypb.Empty{})
if err == nil {
return "SUCCESS"
} else if status.Code(err) == codes.Aborted {
return "FAILURE"
}
return err.Error()
}
resp, err := dtmcli.RestyClient.R().SetBody(branch.Data).
SetQueryParams(dtmcli.MS{

69
examples/busi.pb.go

@ -10,6 +10,7 @@ import (
dtmpb "github.com/yedf/dtm/dtmpb"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
emptypb "google.golang.org/protobuf/types/known/emptypb"
reflect "reflect"
)
@ -26,46 +27,44 @@ 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,
0x11, 0x64, 0x74, 0x6d, 0x70, 0x62, 0x2f, 0x64, 0x74, 0x6d, 0x70, 0x62, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x32, 0x9a, 0x02, 0x0a, 0x04, 0x42, 0x75, 0x73, 0x69, 0x12, 0x30, 0x0a, 0x04, 0x43,
0x61, 0x6c, 0x6c, 0x12, 0x13, 0x2e, 0x64, 0x74, 0x6d, 0x63, 0x6c, 0x69, 0x2e, 0x42, 0x75, 0x73,
0x69, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x64, 0x74, 0x6d, 0x63, 0x6c,
0x69, 0x2e, 0x42, 0x75, 0x73, 0x69, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x33, 0x0a,
0x07, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x49, 0x6e, 0x12, 0x13, 0x2e, 0x64, 0x74, 0x6d, 0x63, 0x6c,
0x69, 0x2e, 0x42, 0x75, 0x73, 0x69, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e,
0x64, 0x74, 0x6d, 0x63, 0x6c, 0x69, 0x2e, 0x42, 0x75, 0x73, 0x69, 0x52, 0x65, 0x70, 0x6c, 0x79,
0x22, 0x00, 0x12, 0x34, 0x0a, 0x08, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x4f, 0x75, 0x74, 0x12, 0x13,
0x2e, 0x64, 0x74, 0x6d, 0x63, 0x6c, 0x69, 0x2e, 0x42, 0x75, 0x73, 0x69, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x64, 0x74, 0x6d, 0x63, 0x6c, 0x69, 0x2e, 0x42, 0x75, 0x73,
0x69, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x39, 0x0a, 0x0d, 0x54, 0x72, 0x61, 0x6e,
0x73, 0x49, 0x6e, 0x52, 0x65, 0x76, 0x65, 0x72, 0x74, 0x12, 0x13, 0x2e, 0x64, 0x74, 0x6d, 0x63,
0x6c, 0x69, 0x2e, 0x42, 0x75, 0x73, 0x69, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11,
0x2e, 0x64, 0x74, 0x6d, 0x63, 0x6c, 0x69, 0x2e, 0x42, 0x75, 0x73, 0x69, 0x52, 0x65, 0x70, 0x6c,
0x79, 0x22, 0x00, 0x12, 0x3a, 0x0a, 0x0e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x4f, 0x75, 0x74, 0x52,
0x65, 0x76, 0x65, 0x72, 0x74, 0x12, 0x13, 0x2e, 0x64, 0x74, 0x6d, 0x63, 0x6c, 0x69, 0x2e, 0x42,
0x75, 0x73, 0x69, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x64, 0x74, 0x6d,
0x63, 0x6c, 0x69, 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,
0x74, 0x6f, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32,
0xf8, 0x01, 0x0a, 0x04, 0x42, 0x75, 0x73, 0x69, 0x12, 0x37, 0x0a, 0x07, 0x54, 0x72, 0x61, 0x6e,
0x73, 0x49, 0x6e, 0x12, 0x12, 0x2e, 0x64, 0x74, 0x6d, 0x70, 0x62, 0x2e, 0x42, 0x75, 0x73, 0x69,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22,
0x00, 0x12, 0x38, 0x0a, 0x08, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x4f, 0x75, 0x74, 0x12, 0x12, 0x2e,
0x64, 0x74, 0x6d, 0x70, 0x62, 0x2e, 0x42, 0x75, 0x73, 0x69, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x3d, 0x0a, 0x0d, 0x54,
0x72, 0x61, 0x6e, 0x73, 0x49, 0x6e, 0x52, 0x65, 0x76, 0x65, 0x72, 0x74, 0x12, 0x12, 0x2e, 0x64,
0x74, 0x6d, 0x70, 0x62, 0x2e, 0x42, 0x75, 0x73, 0x69, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62,
0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x0e, 0x54, 0x72,
0x61, 0x6e, 0x73, 0x4f, 0x75, 0x74, 0x52, 0x65, 0x76, 0x65, 0x72, 0x74, 0x12, 0x12, 0x2e, 0x64,
0x74, 0x6d, 0x70, 0x62, 0x2e, 0x42, 0x75, 0x73, 0x69, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62,
0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 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_goTypes = []interface{}{
(*dtmpb.BusiRequest)(nil), // 0: dtmcli.BusiRequest
(*dtmpb.BusiReply)(nil), // 1: dtmcli.BusiReply
(*dtmpb.BusiRequest)(nil), // 0: dtmpb.BusiRequest
(*emptypb.Empty)(nil), // 1: google.protobuf.Empty
}
var file_examples_busi_proto_depIdxs = []int32{
0, // 0: examples.Busi.Call:input_type -> dtmcli.BusiRequest
0, // 1: examples.Busi.TransIn:input_type -> dtmcli.BusiRequest
0, // 2: examples.Busi.TransOut:input_type -> dtmcli.BusiRequest
0, // 3: examples.Busi.TransInRevert:input_type -> dtmcli.BusiRequest
0, // 4: examples.Busi.TransOutRevert:input_type -> dtmcli.BusiRequest
1, // 5: examples.Busi.Call:output_type -> dtmcli.BusiReply
1, // 6: examples.Busi.TransIn:output_type -> dtmcli.BusiReply
1, // 7: examples.Busi.TransOut:output_type -> dtmcli.BusiReply
1, // 8: examples.Busi.TransInRevert:output_type -> dtmcli.BusiReply
1, // 9: examples.Busi.TransOutRevert:output_type -> dtmcli.BusiReply
5, // [5:10] is the sub-list for method output_type
0, // [0:5] is the sub-list for method input_type
0, // 0: examples.Busi.TransIn:input_type -> dtmpb.BusiRequest
0, // 1: examples.Busi.TransOut:input_type -> dtmpb.BusiRequest
0, // 2: examples.Busi.TransInRevert:input_type -> dtmpb.BusiRequest
0, // 3: examples.Busi.TransOutRevert:input_type -> dtmpb.BusiRequest
1, // 4: examples.Busi.TransIn:output_type -> google.protobuf.Empty
1, // 5: examples.Busi.TransOut:output_type -> google.protobuf.Empty
1, // 6: examples.Busi.TransInRevert:output_type -> google.protobuf.Empty
1, // 7: examples.Busi.TransOutRevert:output_type -> google.protobuf.Empty
4, // [4:8] is the sub-list for method output_type
0, // [0:4] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name

11
examples/busi.proto

@ -4,14 +4,13 @@ package examples;
option go_package = "github.com/yedf/dtm/examples";
import "dtmpb/dtmpb.proto";
import "google/protobuf/empty.proto";
// The dtm service definition.
service Busi {
rpc Call(dtmcli.BusiRequest) returns (dtmcli.BusiReply) {}
rpc TransIn(dtmcli.BusiRequest) returns (dtmcli.BusiReply) {}
rpc TransOut(dtmcli.BusiRequest) returns (dtmcli.BusiReply) {}
rpc TransInRevert(dtmcli.BusiRequest) returns (dtmcli.BusiReply) {}
rpc TransOutRevert(dtmcli.BusiRequest) returns (dtmcli.BusiReply) {}
rpc TransIn(dtmpb.BusiRequest) returns (google.protobuf.Empty) {}
rpc TransOut(dtmpb.BusiRequest) returns (google.protobuf.Empty) {}
rpc TransInRevert(dtmpb.BusiRequest) returns (google.protobuf.Empty) {}
rpc TransOutRevert(dtmpb.BusiRequest) returns (google.protobuf.Empty) {}
}

77
examples/busi_grpc.pb.go

@ -8,6 +8,7 @@ import (
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
emptypb "google.golang.org/protobuf/types/known/emptypb"
)
// This is a compile-time assertion to ensure that this generated file
@ -19,11 +20,10 @@ const _ = grpc.SupportPackageIsVersion7
//
// 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 {
Call(ctx context.Context, in *dtmpb.BusiRequest, opts ...grpc.CallOption) (*dtmpb.BusiReply, error)
TransIn(ctx context.Context, in *dtmpb.BusiRequest, opts ...grpc.CallOption) (*dtmpb.BusiReply, error)
TransOut(ctx context.Context, in *dtmpb.BusiRequest, opts ...grpc.CallOption) (*dtmpb.BusiReply, error)
TransInRevert(ctx context.Context, in *dtmpb.BusiRequest, opts ...grpc.CallOption) (*dtmpb.BusiReply, error)
TransOutRevert(ctx context.Context, in *dtmpb.BusiRequest, opts ...grpc.CallOption) (*dtmpb.BusiReply, error)
TransIn(ctx context.Context, in *dtmpb.BusiRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
TransOut(ctx context.Context, in *dtmpb.BusiRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
TransInRevert(ctx context.Context, in *dtmpb.BusiRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
TransOutRevert(ctx context.Context, in *dtmpb.BusiRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
}
type busiClient struct {
@ -34,17 +34,8 @@ func NewBusiClient(cc grpc.ClientConnInterface) BusiClient {
return &busiClient{cc}
}
func (c *busiClient) Call(ctx context.Context, in *dtmpb.BusiRequest, opts ...grpc.CallOption) (*dtmpb.BusiReply, error) {
out := new(dtmpb.BusiReply)
err := c.cc.Invoke(ctx, "/examples.Busi/Call", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *busiClient) TransIn(ctx context.Context, in *dtmpb.BusiRequest, opts ...grpc.CallOption) (*dtmpb.BusiReply, error) {
out := new(dtmpb.BusiReply)
func (c *busiClient) TransIn(ctx context.Context, in *dtmpb.BusiRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
out := new(emptypb.Empty)
err := c.cc.Invoke(ctx, "/examples.Busi/TransIn", in, out, opts...)
if err != nil {
return nil, err
@ -52,8 +43,8 @@ func (c *busiClient) TransIn(ctx context.Context, in *dtmpb.BusiRequest, opts ..
return out, nil
}
func (c *busiClient) TransOut(ctx context.Context, in *dtmpb.BusiRequest, opts ...grpc.CallOption) (*dtmpb.BusiReply, error) {
out := new(dtmpb.BusiReply)
func (c *busiClient) TransOut(ctx context.Context, in *dtmpb.BusiRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
out := new(emptypb.Empty)
err := c.cc.Invoke(ctx, "/examples.Busi/TransOut", in, out, opts...)
if err != nil {
return nil, err
@ -61,8 +52,8 @@ func (c *busiClient) TransOut(ctx context.Context, in *dtmpb.BusiRequest, opts .
return out, nil
}
func (c *busiClient) TransInRevert(ctx context.Context, in *dtmpb.BusiRequest, opts ...grpc.CallOption) (*dtmpb.BusiReply, error) {
out := new(dtmpb.BusiReply)
func (c *busiClient) TransInRevert(ctx context.Context, in *dtmpb.BusiRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
out := new(emptypb.Empty)
err := c.cc.Invoke(ctx, "/examples.Busi/TransInRevert", in, out, opts...)
if err != nil {
return nil, err
@ -70,8 +61,8 @@ func (c *busiClient) TransInRevert(ctx context.Context, in *dtmpb.BusiRequest, o
return out, nil
}
func (c *busiClient) TransOutRevert(ctx context.Context, in *dtmpb.BusiRequest, opts ...grpc.CallOption) (*dtmpb.BusiReply, error) {
out := new(dtmpb.BusiReply)
func (c *busiClient) TransOutRevert(ctx context.Context, in *dtmpb.BusiRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
out := new(emptypb.Empty)
err := c.cc.Invoke(ctx, "/examples.Busi/TransOutRevert", in, out, opts...)
if err != nil {
return nil, err
@ -83,11 +74,10 @@ func (c *busiClient) TransOutRevert(ctx context.Context, in *dtmpb.BusiRequest,
// All implementations must embed UnimplementedBusiServer
// for forward compatibility
type BusiServer interface {
Call(context.Context, *dtmpb.BusiRequest) (*dtmpb.BusiReply, error)
TransIn(context.Context, *dtmpb.BusiRequest) (*dtmpb.BusiReply, error)
TransOut(context.Context, *dtmpb.BusiRequest) (*dtmpb.BusiReply, error)
TransInRevert(context.Context, *dtmpb.BusiRequest) (*dtmpb.BusiReply, error)
TransOutRevert(context.Context, *dtmpb.BusiRequest) (*dtmpb.BusiReply, error)
TransIn(context.Context, *dtmpb.BusiRequest) (*emptypb.Empty, error)
TransOut(context.Context, *dtmpb.BusiRequest) (*emptypb.Empty, error)
TransInRevert(context.Context, *dtmpb.BusiRequest) (*emptypb.Empty, error)
TransOutRevert(context.Context, *dtmpb.BusiRequest) (*emptypb.Empty, error)
mustEmbedUnimplementedBusiServer()
}
@ -95,19 +85,16 @@ type BusiServer interface {
type UnimplementedBusiServer struct {
}
func (UnimplementedBusiServer) Call(context.Context, *dtmpb.BusiRequest) (*dtmpb.BusiReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method Call not implemented")
}
func (UnimplementedBusiServer) TransIn(context.Context, *dtmpb.BusiRequest) (*dtmpb.BusiReply, error) {
func (UnimplementedBusiServer) TransIn(context.Context, *dtmpb.BusiRequest) (*emptypb.Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method TransIn not implemented")
}
func (UnimplementedBusiServer) TransOut(context.Context, *dtmpb.BusiRequest) (*dtmpb.BusiReply, error) {
func (UnimplementedBusiServer) TransOut(context.Context, *dtmpb.BusiRequest) (*emptypb.Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method TransOut not implemented")
}
func (UnimplementedBusiServer) TransInRevert(context.Context, *dtmpb.BusiRequest) (*dtmpb.BusiReply, error) {
func (UnimplementedBusiServer) TransInRevert(context.Context, *dtmpb.BusiRequest) (*emptypb.Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method TransInRevert not implemented")
}
func (UnimplementedBusiServer) TransOutRevert(context.Context, *dtmpb.BusiRequest) (*dtmpb.BusiReply, error) {
func (UnimplementedBusiServer) TransOutRevert(context.Context, *dtmpb.BusiRequest) (*emptypb.Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method TransOutRevert not implemented")
}
func (UnimplementedBusiServer) mustEmbedUnimplementedBusiServer() {}
@ -123,24 +110,6 @@ func RegisterBusiServer(s grpc.ServiceRegistrar, srv BusiServer) {
s.RegisterService(&Busi_ServiceDesc, srv)
}
func _Busi_Call_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(dtmpb.BusiRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(BusiServer).Call(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/examples.Busi/Call",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(BusiServer).Call(ctx, req.(*dtmpb.BusiRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Busi_TransIn_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(dtmpb.BusiRequest)
if err := dec(in); err != nil {
@ -220,10 +189,6 @@ var Busi_ServiceDesc = grpc.ServiceDesc{
ServiceName: "examples.Busi",
HandlerType: (*BusiServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Call",
Handler: _Busi_Call_Handler,
},
{
MethodName: "TransIn",
Handler: _Busi_TransIn_Handler,

14
examples/main_grpc.go

@ -5,6 +5,7 @@ import (
"github.com/yedf/dtm/dtmcli"
dtmpb "github.com/yedf/dtm/dtmpb"
"google.golang.org/protobuf/types/known/emptypb"
)
// busiServer is used to implement helloworld.GreeterServer.
@ -12,21 +13,16 @@ type busiServer struct {
UnimplementedBusiServer
}
func (s *busiServer) Call(ctx context.Context, in *dtmpb.BusiRequest) (*dtmpb.BusiReply, error) {
dtmcli.Logf("busiServer %s received: %v", dtmcli.GetFuncName(), in)
return &dtmpb.BusiReply{DtmResult: "SUCCESS", DtmMessage: "ok"}, nil
}
func (s *busiServer) TransIn(ctx context.Context, in *dtmpb.BusiRequest) (*dtmpb.BusiReply, error) {
func (s *busiServer) TransIn(ctx context.Context, in *dtmpb.BusiRequest) (*emptypb.Empty, error) {
req := TransReq{}
dtmcli.MustUnmarshal(in.AppData, &req)
dtmcli.Logf("busiServer %s received: %v %v", dtmcli.GetFuncName(), in.Info, req)
return &dtmpb.BusiReply{DtmResult: "SUCCESS", DtmMessage: "ok"}, nil
return &emptypb.Empty{}, nil
}
func (s *busiServer) TransOut(ctx context.Context, in *dtmpb.BusiRequest) (*dtmpb.BusiReply, error) {
func (s *busiServer) TransOut(ctx context.Context, in *dtmpb.BusiRequest) (*emptypb.Empty, error) {
req := TransReq{}
dtmcli.MustUnmarshal(in.AppData, &req)
dtmcli.Logf("busiServer %s received: %v %v", dtmcli.GetFuncName(), in.Info, req)
return &dtmpb.BusiReply{DtmResult: "SUCCESS", DtmMessage: "ok"}, nil
return &emptypb.Empty{}, nil
}

Loading…
Cancel
Save