Browse Source

replace registerXaBranch registerTccBranch to registerBranch

pull/52/head
yedf2 4 years ago
parent
commit
c11c2bec3f
  1. 287
      dtmgrpc/dtmgimp/dtmgimp.pb.go
  2. 20
      dtmgrpc/dtmgimp/dtmgimp.proto
  3. 62
      dtmgrpc/dtmgimp/dtmgimp_grpc.pb.go
  4. 13
      dtmgrpc/tcc.go
  5. 12
      dtmgrpc/xa.go
  6. 35
      dtmsvr/api.go
  7. 24
      dtmsvr/api_grpc.go
  8. 16
      dtmsvr/api_http.go

287
dtmgrpc/dtmgimp/dtmgimp.pb.go

@ -231,11 +231,6 @@ type DtmBranchInfo struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Gid string `protobuf:"bytes,1,opt,name=Gid,proto3" json:"Gid,omitempty"`
TransType string `protobuf:"bytes,2,opt,name=TransType,proto3" json:"TransType,omitempty"`
BranchID string `protobuf:"bytes,3,opt,name=BranchID,proto3" json:"BranchID,omitempty"`
BranchType string `protobuf:"bytes,4,opt,name=BranchType,proto3" json:"BranchType,omitempty"`
}
func (x *DtmBranchInfo) Reset() {
@ -270,47 +265,21 @@ func (*DtmBranchInfo) Descriptor() ([]byte, []int) {
return file_dtmgrpc_dtmgimp_dtmgimp_proto_rawDescGZIP(), []int{3}
}
func (x *DtmBranchInfo) GetGid() string {
if x != nil {
return x.Gid
}
return ""
}
func (x *DtmBranchInfo) GetTransType() string {
if x != nil {
return x.TransType
}
return ""
}
func (x *DtmBranchInfo) GetBranchID() string {
if x != nil {
return x.BranchID
}
return ""
}
func (x *DtmBranchInfo) GetBranchType() string {
if x != nil {
return x.BranchType
}
return ""
}
type DtmTccBranchRequest struct {
type DtmBranchRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Info *DtmBranchInfo `protobuf:"bytes,1,opt,name=Info,proto3" json:"Info,omitempty"`
BusiPayload []byte `protobuf:"bytes,2,opt,name=BusiPayload,proto3" json:"BusiPayload,omitempty"`
Confirm string `protobuf:"bytes,3,opt,name=Confirm,proto3" json:"Confirm,omitempty"`
Cancel string `protobuf:"bytes,4,opt,name=Cancel,proto3" json:"Cancel,omitempty"`
Gid string `protobuf:"bytes,1,opt,name=Gid,proto3" json:"Gid,omitempty"`
TransType string `protobuf:"bytes,2,opt,name=TransType,proto3" json:"TransType,omitempty"`
BranchID string `protobuf:"bytes,3,opt,name=BranchID,proto3" json:"BranchID,omitempty"`
BranchType string `protobuf:"bytes,4,opt,name=BranchType,proto3" json:"BranchType,omitempty"`
Data map[string]string `protobuf:"bytes,5,rep,name=Data,proto3" json:"Data,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
BusiPayload []byte `protobuf:"bytes,6,opt,name=BusiPayload,proto3" json:"BusiPayload,omitempty"`
}
func (x *DtmTccBranchRequest) Reset() {
*x = DtmTccBranchRequest{}
func (x *DtmBranchRequest) Reset() {
*x = DtmBranchRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_dtmgrpc_dtmgimp_dtmgimp_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@ -318,13 +287,13 @@ func (x *DtmTccBranchRequest) Reset() {
}
}
func (x *DtmTccBranchRequest) String() string {
func (x *DtmBranchRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DtmTccBranchRequest) ProtoMessage() {}
func (*DtmBranchRequest) ProtoMessage() {}
func (x *DtmTccBranchRequest) ProtoReflect() protoreflect.Message {
func (x *DtmBranchRequest) ProtoReflect() protoreflect.Message {
mi := &file_dtmgrpc_dtmgimp_dtmgimp_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@ -336,102 +305,53 @@ func (x *DtmTccBranchRequest) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x)
}
// Deprecated: Use DtmTccBranchRequest.ProtoReflect.Descriptor instead.
func (*DtmTccBranchRequest) Descriptor() ([]byte, []int) {
// Deprecated: Use DtmBranchRequest.ProtoReflect.Descriptor instead.
func (*DtmBranchRequest) Descriptor() ([]byte, []int) {
return file_dtmgrpc_dtmgimp_dtmgimp_proto_rawDescGZIP(), []int{4}
}
func (x *DtmTccBranchRequest) GetInfo() *DtmBranchInfo {
func (x *DtmBranchRequest) GetGid() string {
if x != nil {
return x.Info
return x.Gid
}
return nil
return ""
}
func (x *DtmTccBranchRequest) GetBusiPayload() []byte {
func (x *DtmBranchRequest) GetTransType() string {
if x != nil {
return x.BusiPayload
return x.TransType
}
return nil
return ""
}
func (x *DtmTccBranchRequest) GetConfirm() string {
func (x *DtmBranchRequest) GetBranchID() string {
if x != nil {
return x.Confirm
return x.BranchID
}
return ""
}
func (x *DtmTccBranchRequest) GetCancel() string {
func (x *DtmBranchRequest) GetBranchType() string {
if x != nil {
return x.Cancel
return x.BranchType
}
return ""
}
type DtmXaBranchRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Info *DtmBranchInfo `protobuf:"bytes,1,opt,name=Info,proto3" json:"Info,omitempty"`
BusiPayload []byte `protobuf:"bytes,2,opt,name=BusiPayload,proto3" json:"BusiPayload,omitempty"`
Notify string `protobuf:"bytes,3,opt,name=Notify,proto3" json:"Notify,omitempty"` // dtm will call this url to commit/rollback
}
func (x *DtmXaBranchRequest) Reset() {
*x = DtmXaBranchRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_dtmgrpc_dtmgimp_dtmgimp_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DtmXaBranchRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DtmXaBranchRequest) ProtoMessage() {}
func (x *DtmXaBranchRequest) ProtoReflect() protoreflect.Message {
mi := &file_dtmgrpc_dtmgimp_dtmgimp_proto_msgTypes[5]
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 DtmXaBranchRequest.ProtoReflect.Descriptor instead.
func (*DtmXaBranchRequest) Descriptor() ([]byte, []int) {
return file_dtmgrpc_dtmgimp_dtmgimp_proto_rawDescGZIP(), []int{5}
}
func (x *DtmXaBranchRequest) GetInfo() *DtmBranchInfo {
func (x *DtmBranchRequest) GetData() map[string]string {
if x != nil {
return x.Info
return x.Data
}
return nil
}
func (x *DtmXaBranchRequest) GetBusiPayload() []byte {
func (x *DtmBranchRequest) GetBusiPayload() []byte {
if x != nil {
return x.BusiPayload
}
return nil
}
func (x *DtmXaBranchRequest) GetNotify() string {
if x != nil {
return x.Notify
}
return ""
}
var File_dtmgrpc_dtmgimp_dtmgimp_proto protoreflect.FileDescriptor
var file_dtmgrpc_dtmgimp_dtmgimp_proto_rawDesc = []byte{
@ -465,59 +385,47 @@ var file_dtmgrpc_dtmgimp_dtmgimp_proto_rawDesc = []byte{
0x05, 0x53, 0x74, 0x65, 0x70, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x53, 0x74,
0x65, 0x70, 0x73, 0x22, 0x1f, 0x0a, 0x0b, 0x44, 0x74, 0x6d, 0x47, 0x69, 0x64, 0x52, 0x65, 0x70,
0x6c, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x47, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x03, 0x47, 0x69, 0x64, 0x22, 0x7b, 0x0a, 0x0d, 0x44, 0x74, 0x6d, 0x42, 0x72, 0x61, 0x6e, 0x63,
0x68, 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, 0x22, 0x95, 0x01, 0x0a, 0x13, 0x44, 0x74, 0x6d, 0x54, 0x63, 0x63, 0x42, 0x72, 0x61, 0x6e,
0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x04, 0x49, 0x6e, 0x66,
0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x64, 0x74, 0x6d, 0x67, 0x69, 0x6d,
0x70, 0x2e, 0x44, 0x74, 0x6d, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x49, 0x6e, 0x66, 0x6f, 0x52,
0x04, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x20, 0x0a, 0x0b, 0x42, 0x75, 0x73, 0x69, 0x50, 0x61, 0x79,
0x6c, 0x6f, 0x61, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x42, 0x75, 0x73, 0x69,
0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x43, 0x6f, 0x6e, 0x66, 0x69,
0x72, 0x6d, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x72,
0x6d, 0x12, 0x16, 0x0a, 0x06, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28,
0x09, 0x52, 0x06, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x22, 0x7a, 0x0a, 0x12, 0x44, 0x74, 0x6d,
0x58, 0x61, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12,
0x2a, 0x0a, 0x04, 0x49, 0x6e, 0x66, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e,
0x64, 0x74, 0x6d, 0x67, 0x69, 0x6d, 0x70, 0x2e, 0x44, 0x74, 0x6d, 0x42, 0x72, 0x61, 0x6e, 0x63,
0x68, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x20, 0x0a, 0x0b, 0x42,
0x75, 0x73, 0x69, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c,
0x52, 0x0b, 0x42, 0x75, 0x73, 0x69, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x16, 0x0a,
0x06, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x4e,
0x6f, 0x74, 0x69, 0x66, 0x79, 0x32, 0x82, 0x03, 0x0a, 0x03, 0x44, 0x74, 0x6d, 0x12, 0x38, 0x0a,
0x06, 0x4e, 0x65, 0x77, 0x47, 0x69, 0x64, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a,
0x14, 0x2e, 0x64, 0x74, 0x6d, 0x67, 0x69, 0x6d, 0x70, 0x2e, 0x44, 0x74, 0x6d, 0x47, 0x69, 0x64,
0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x37, 0x0a, 0x06, 0x53, 0x75, 0x62, 0x6d, 0x69,
0x74, 0x12, 0x13, 0x2e, 0x64, 0x74, 0x6d, 0x67, 0x69, 0x6d, 0x70, 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,
0x12, 0x38, 0x0a, 0x07, 0x50, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x12, 0x13, 0x2e, 0x64, 0x74,
0x6d, 0x67, 0x69, 0x6d, 0x70, 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, 0x12, 0x36, 0x0a, 0x05, 0x41, 0x62,
0x6f, 0x72, 0x74, 0x12, 0x13, 0x2e, 0x64, 0x74, 0x6d, 0x67, 0x69, 0x6d, 0x70, 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, 0x12, 0x4b, 0x0a, 0x11, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x54, 0x63,
0x63, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x12, 0x1c, 0x2e, 0x64, 0x74, 0x6d, 0x67, 0x69, 0x6d,
0x70, 0x2e, 0x44, 0x74, 0x6d, 0x54, 0x63, 0x63, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x52, 0x65,
0x03, 0x47, 0x69, 0x64, 0x22, 0x0f, 0x0a, 0x0d, 0x44, 0x74, 0x6d, 0x42, 0x72, 0x61, 0x6e, 0x63,
0x68, 0x49, 0x6e, 0x66, 0x6f, 0x22, 0x92, 0x02, 0x0a, 0x10, 0x44, 0x74, 0x6d, 0x42, 0x72, 0x61,
0x6e, 0x63, 0x68, 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, 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, 0x37, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x05,
0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x64, 0x74, 0x6d, 0x67, 0x69, 0x6d, 0x70, 0x2e, 0x44,
0x74, 0x6d, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e,
0x44, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x12,
0x20, 0x0a, 0x0b, 0x42, 0x75, 0x73, 0x69, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x06,
0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x42, 0x75, 0x73, 0x69, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61,
0x64, 0x1a, 0x37, 0x0a, 0x09, 0x44, 0x61, 0x74, 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, 0x32, 0xb1, 0x02, 0x0a, 0x03, 0x44,
0x74, 0x6d, 0x12, 0x38, 0x0a, 0x06, 0x4e, 0x65, 0x77, 0x47, 0x69, 0x64, 0x12, 0x16, 0x2e, 0x67,
0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45,
0x6d, 0x70, 0x74, 0x79, 0x1a, 0x14, 0x2e, 0x64, 0x74, 0x6d, 0x67, 0x69, 0x6d, 0x70, 0x2e, 0x44,
0x74, 0x6d, 0x47, 0x69, 0x64, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x37, 0x0a, 0x06,
0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x12, 0x13, 0x2e, 0x64, 0x74, 0x6d, 0x67, 0x69, 0x6d, 0x70,
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, 0x12, 0x38, 0x0a, 0x07, 0x50, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65,
0x12, 0x13, 0x2e, 0x64, 0x74, 0x6d, 0x67, 0x69, 0x6d, 0x70, 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, 0x12,
0x49, 0x0a, 0x10, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x58, 0x61, 0x42, 0x72, 0x61,
0x6e, 0x63, 0x68, 0x12, 0x1b, 0x2e, 0x64, 0x74, 0x6d, 0x67, 0x69, 0x6d, 0x70, 0x2e, 0x44, 0x74,
0x6d, 0x58, 0x61, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 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, 0x25, 0x5a, 0x23, 0x67, 0x69,
0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x79, 0x65, 0x64, 0x66, 0x2f, 0x64, 0x74,
0x6d, 0x2f, 0x64, 0x74, 0x6d, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x64, 0x74, 0x6d, 0x67, 0x69, 0x6d,
0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x36, 0x0a, 0x05, 0x41, 0x62, 0x6f, 0x72, 0x74, 0x12, 0x13, 0x2e, 0x64, 0x74, 0x6d, 0x67, 0x69,
0x6d, 0x70, 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, 0x12, 0x45, 0x0a, 0x0e, 0x52, 0x65, 0x67, 0x69, 0x73,
0x74, 0x65, 0x72, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x12, 0x19, 0x2e, 0x64, 0x74, 0x6d, 0x67,
0x69, 0x6d, 0x70, 0x2e, 0x44, 0x74, 0x6d, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 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, 0x25,
0x5a, 0x23, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x79, 0x65, 0x64,
0x66, 0x2f, 0x64, 0x74, 0x6d, 0x2f, 0x64, 0x74, 0x6d, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x64, 0x74,
0x6d, 0x67, 0x69, 0x6d, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@ -534,35 +442,32 @@ func file_dtmgrpc_dtmgimp_dtmgimp_proto_rawDescGZIP() []byte {
var file_dtmgrpc_dtmgimp_dtmgimp_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
var file_dtmgrpc_dtmgimp_dtmgimp_proto_goTypes = []interface{}{
(*DtmTransOptions)(nil), // 0: dtmgimp.DtmTransOptions
(*DtmRequest)(nil), // 1: dtmgimp.DtmRequest
(*DtmGidReply)(nil), // 2: dtmgimp.DtmGidReply
(*DtmBranchInfo)(nil), // 3: dtmgimp.DtmBranchInfo
(*DtmTccBranchRequest)(nil), // 4: dtmgimp.DtmTccBranchRequest
(*DtmXaBranchRequest)(nil), // 5: dtmgimp.DtmXaBranchRequest
(*emptypb.Empty)(nil), // 6: google.protobuf.Empty
(*DtmTransOptions)(nil), // 0: dtmgimp.DtmTransOptions
(*DtmRequest)(nil), // 1: dtmgimp.DtmRequest
(*DtmGidReply)(nil), // 2: dtmgimp.DtmGidReply
(*DtmBranchInfo)(nil), // 3: dtmgimp.DtmBranchInfo
(*DtmBranchRequest)(nil), // 4: dtmgimp.DtmBranchRequest
nil, // 5: dtmgimp.DtmBranchRequest.DataEntry
(*emptypb.Empty)(nil), // 6: google.protobuf.Empty
}
var file_dtmgrpc_dtmgimp_dtmgimp_proto_depIdxs = []int32{
0, // 0: dtmgimp.DtmRequest.TransOptions:type_name -> dtmgimp.DtmTransOptions
3, // 1: dtmgimp.DtmTccBranchRequest.Info:type_name -> dtmgimp.DtmBranchInfo
3, // 2: dtmgimp.DtmXaBranchRequest.Info:type_name -> dtmgimp.DtmBranchInfo
6, // 3: dtmgimp.Dtm.NewGid:input_type -> google.protobuf.Empty
1, // 4: dtmgimp.Dtm.Submit:input_type -> dtmgimp.DtmRequest
1, // 5: dtmgimp.Dtm.Prepare:input_type -> dtmgimp.DtmRequest
1, // 6: dtmgimp.Dtm.Abort:input_type -> dtmgimp.DtmRequest
4, // 7: dtmgimp.Dtm.RegisterTccBranch:input_type -> dtmgimp.DtmTccBranchRequest
5, // 8: dtmgimp.Dtm.RegisterXaBranch:input_type -> dtmgimp.DtmXaBranchRequest
2, // 9: dtmgimp.Dtm.NewGid:output_type -> dtmgimp.DtmGidReply
6, // 10: dtmgimp.Dtm.Submit:output_type -> google.protobuf.Empty
6, // 11: dtmgimp.Dtm.Prepare:output_type -> google.protobuf.Empty
6, // 12: dtmgimp.Dtm.Abort:output_type -> google.protobuf.Empty
6, // 13: dtmgimp.Dtm.RegisterTccBranch:output_type -> google.protobuf.Empty
6, // 14: dtmgimp.Dtm.RegisterXaBranch:output_type -> google.protobuf.Empty
9, // [9:15] is the sub-list for method output_type
3, // [3:9] 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
5, // 1: dtmgimp.DtmBranchRequest.Data:type_name -> dtmgimp.DtmBranchRequest.DataEntry
6, // 2: dtmgimp.Dtm.NewGid:input_type -> google.protobuf.Empty
1, // 3: dtmgimp.Dtm.Submit:input_type -> dtmgimp.DtmRequest
1, // 4: dtmgimp.Dtm.Prepare:input_type -> dtmgimp.DtmRequest
1, // 5: dtmgimp.Dtm.Abort:input_type -> dtmgimp.DtmRequest
4, // 6: dtmgimp.Dtm.RegisterBranch:input_type -> dtmgimp.DtmBranchRequest
2, // 7: dtmgimp.Dtm.NewGid:output_type -> dtmgimp.DtmGidReply
6, // 8: dtmgimp.Dtm.Submit:output_type -> google.protobuf.Empty
6, // 9: dtmgimp.Dtm.Prepare:output_type -> google.protobuf.Empty
6, // 10: dtmgimp.Dtm.Abort:output_type -> google.protobuf.Empty
6, // 11: dtmgimp.Dtm.RegisterBranch:output_type -> google.protobuf.Empty
7, // [7:12] is the sub-list for method output_type
2, // [2:7] 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_dtmgrpc_dtmgimp_dtmgimp_proto_init() }
@ -620,19 +525,7 @@ func file_dtmgrpc_dtmgimp_dtmgimp_proto_init() {
}
}
file_dtmgrpc_dtmgimp_dtmgimp_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DtmTccBranchRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_dtmgrpc_dtmgimp_dtmgimp_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DtmXaBranchRequest); i {
switch v := v.(*DtmBranchRequest); i {
case 0:
return &v.state
case 1:

20
dtmgrpc/dtmgimp/dtmgimp.proto

@ -11,8 +11,7 @@ service Dtm {
rpc Submit(DtmRequest) returns (google.protobuf.Empty) {}
rpc Prepare(DtmRequest) returns (google.protobuf.Empty) {}
rpc Abort(DtmRequest) returns (google.protobuf.Empty) {}
rpc RegisterTccBranch(DtmTccBranchRequest) returns (google.protobuf.Empty) {}
rpc RegisterXaBranch(DtmXaBranchRequest) returns (google.protobuf.Empty) {}
rpc RegisterBranch(DtmBranchRequest) returns (google.protobuf.Empty) {}
}
message DtmTransOptions {
@ -37,21 +36,14 @@ message DtmGidReply {
}
message DtmBranchInfo {
}
message DtmBranchRequest {
string Gid = 1;
string TransType = 2;
string BranchID = 3;
string BranchType = 4;
map<string, string> Data = 5;
bytes BusiPayload = 6;
}
message DtmTccBranchRequest {
DtmBranchInfo Info = 1;
bytes BusiPayload = 2;
string Confirm = 3;
string Cancel = 4;
}
message DtmXaBranchRequest {
DtmBranchInfo Info = 1;
bytes BusiPayload = 2;
string Notify = 3; // dtm will call this url to commit/rollback
}

62
dtmgrpc/dtmgimp/dtmgimp_grpc.pb.go

@ -23,8 +23,7 @@ type DtmClient interface {
Submit(ctx context.Context, in *DtmRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
Prepare(ctx context.Context, in *DtmRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
Abort(ctx context.Context, in *DtmRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
RegisterTccBranch(ctx context.Context, in *DtmTccBranchRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
RegisterXaBranch(ctx context.Context, in *DtmXaBranchRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
RegisterBranch(ctx context.Context, in *DtmBranchRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
}
type dtmClient struct {
@ -71,18 +70,9 @@ func (c *dtmClient) Abort(ctx context.Context, in *DtmRequest, opts ...grpc.Call
return out, nil
}
func (c *dtmClient) RegisterTccBranch(ctx context.Context, in *DtmTccBranchRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
func (c *dtmClient) RegisterBranch(ctx context.Context, in *DtmBranchRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
out := new(emptypb.Empty)
err := c.cc.Invoke(ctx, "/dtmgimp.Dtm/RegisterTccBranch", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *dtmClient) RegisterXaBranch(ctx context.Context, in *DtmXaBranchRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
out := new(emptypb.Empty)
err := c.cc.Invoke(ctx, "/dtmgimp.Dtm/RegisterXaBranch", in, out, opts...)
err := c.cc.Invoke(ctx, "/dtmgimp.Dtm/RegisterBranch", in, out, opts...)
if err != nil {
return nil, err
}
@ -97,8 +87,7 @@ type DtmServer interface {
Submit(context.Context, *DtmRequest) (*emptypb.Empty, error)
Prepare(context.Context, *DtmRequest) (*emptypb.Empty, error)
Abort(context.Context, *DtmRequest) (*emptypb.Empty, error)
RegisterTccBranch(context.Context, *DtmTccBranchRequest) (*emptypb.Empty, error)
RegisterXaBranch(context.Context, *DtmXaBranchRequest) (*emptypb.Empty, error)
RegisterBranch(context.Context, *DtmBranchRequest) (*emptypb.Empty, error)
mustEmbedUnimplementedDtmServer()
}
@ -118,11 +107,8 @@ func (UnimplementedDtmServer) Prepare(context.Context, *DtmRequest) (*emptypb.Em
func (UnimplementedDtmServer) Abort(context.Context, *DtmRequest) (*emptypb.Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method Abort not implemented")
}
func (UnimplementedDtmServer) RegisterTccBranch(context.Context, *DtmTccBranchRequest) (*emptypb.Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method RegisterTccBranch not implemented")
}
func (UnimplementedDtmServer) RegisterXaBranch(context.Context, *DtmXaBranchRequest) (*emptypb.Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method RegisterXaBranch not implemented")
func (UnimplementedDtmServer) RegisterBranch(context.Context, *DtmBranchRequest) (*emptypb.Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method RegisterBranch not implemented")
}
func (UnimplementedDtmServer) mustEmbedUnimplementedDtmServer() {}
@ -209,38 +195,20 @@ func _Dtm_Abort_Handler(srv interface{}, ctx context.Context, dec func(interface
return interceptor(ctx, in, info, handler)
}
func _Dtm_RegisterTccBranch_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(DtmTccBranchRequest)
func _Dtm_RegisterBranch_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(DtmBranchRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(DtmServer).RegisterTccBranch(ctx, in)
return srv.(DtmServer).RegisterBranch(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/dtmgimp.Dtm/RegisterTccBranch",
FullMethod: "/dtmgimp.Dtm/RegisterBranch",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(DtmServer).RegisterTccBranch(ctx, req.(*DtmTccBranchRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Dtm_RegisterXaBranch_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(DtmXaBranchRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(DtmServer).RegisterXaBranch(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/dtmgimp.Dtm/RegisterXaBranch",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(DtmServer).RegisterXaBranch(ctx, req.(*DtmXaBranchRequest))
return srv.(DtmServer).RegisterBranch(ctx, req.(*DtmBranchRequest))
}
return interceptor(ctx, in, info, handler)
}
@ -269,12 +237,8 @@ var Dtm_ServiceDesc = grpc.ServiceDesc{
Handler: _Dtm_Abort_Handler,
},
{
MethodName: "RegisterTccBranch",
Handler: _Dtm_RegisterTccBranch_Handler,
},
{
MethodName: "RegisterXaBranch",
Handler: _Dtm_RegisterXaBranch_Handler,
MethodName: "RegisterBranch",
Handler: _Dtm_RegisterBranch_Handler,
},
},
Streams: []grpc.StreamDesc{},

13
dtmgrpc/tcc.go

@ -66,15 +66,12 @@ func TccFromGrpc(ctx context.Context) (*TccGrpc, error) {
func (t *TccGrpc) CallBranch(busiMsg proto.Message, tryURL string, confirmURL string, cancelURL string, reply interface{}) error {
branchID := t.NewSubBranchID()
bd, err := proto.Marshal(busiMsg)
_, err = dtmgimp.MustGetDtmClient(t.Dtm).RegisterTccBranch(context.Background(), &dtmgimp.DtmTccBranchRequest{
Info: &dtmgimp.DtmBranchInfo{
Gid: t.Gid,
TransType: t.TransType,
BranchID: branchID,
},
_, err = dtmgimp.MustGetDtmClient(t.Dtm).RegisterBranch(context.Background(), &dtmgimp.DtmBranchRequest{
Gid: t.Gid,
TransType: t.TransType,
BranchID: branchID,
BusiPayload: bd,
Confirm: confirmURL,
Cancel: cancelURL,
Data: map[string]string{"confirm": confirmURL, "cancel": cancelURL},
})
if err != nil {
return err

12
dtmgrpc/xa.go

@ -70,14 +70,12 @@ func (xc *XaGrpcClient) XaLocalTransaction(ctx context.Context, msg proto.Messag
if err != nil {
return err
}
_, err = dtmgimp.MustGetDtmClient(xa.Dtm).RegisterXaBranch(context.Background(), &dtmgimp.DtmXaBranchRequest{
Info: &dtmgimp.DtmBranchInfo{
Gid: xa.Gid,
BranchID: xa.BranchID,
TransType: xa.TransType,
},
_, err = dtmgimp.MustGetDtmClient(xa.Dtm).RegisterBranch(context.Background(), &dtmgimp.DtmBranchRequest{
Gid: xa.Gid,
BranchID: xa.BranchID,
TransType: xa.TransType,
BusiPayload: data,
Notify: xc.NotifyURL,
Data: map[string]string{"url": xc.NotifyURL},
})
return err
})

35
dtmsvr/api.go

@ -46,7 +46,7 @@ func svcAbort(t *TransGlobal) (interface{}, error) {
return dbt.Process(db), nil
}
func svcRegisterTccBranch(branch *TransBranch, data map[string]string) (interface{}, error) {
func svcRegisterBranch(branch *TransBranch, data map[string]string) (interface{}, error) {
db := dbGet()
dbt := transFromDb(db, branch.Gid)
if dbt.Status != dtmcli.StatusPrepared {
@ -54,9 +54,18 @@ func svcRegisterTccBranch(branch *TransBranch, data map[string]string) (interfac
}
branches := []TransBranch{*branch, *branch}
for i, b := range []string{dtmcli.BranchCancel, dtmcli.BranchConfirm} {
branches[i].BranchType = b
branches[i].URL = data[b]
if dbt.TransType == "tcc" {
for i, b := range []string{dtmcli.BranchCancel, dtmcli.BranchConfirm} {
branches[i].BranchType = b
branches[i].URL = data[b]
}
} else if dbt.TransType == "xa" {
branches[0].BranchType = dtmcli.BranchRollback
branches[0].URL = data["url"]
branches[1].BranchType = dtmcli.BranchCommit
branches[1].URL = data["url"]
} else {
return nil, fmt.Errorf("unknow trans type: %s", dbt.TransType)
}
db.Must().Clauses(clause.OnConflict{
@ -66,21 +75,3 @@ func svcRegisterTccBranch(branch *TransBranch, data map[string]string) (interfac
global.touch(dbGet(), cronKeep)
return dtmcli.MapSuccess, nil
}
func svcRegisterXaBranch(branch *TransBranch) (interface{}, error) {
branch.Status = dtmcli.StatusPrepared
db := dbGet()
dbt := transFromDb(db, branch.Gid)
if dbt.Status != dtmcli.StatusPrepared {
return map[string]interface{}{"dtm_result": dtmcli.ResultFailure, "message": fmt.Sprintf("current status: %s cannot register branch", dbt.Status)}, nil
}
branches := []TransBranch{*branch, *branch}
branches[0].BranchType = dtmcli.BranchRollback
branches[1].BranchType = dtmcli.BranchCommit
db.Must().Clauses(clause.OnConflict{
DoNothing: true,
}).Create(branches)
global := TransGlobal{Gid: branch.Gid}
global.touch(db, cronKeep)
return dtmcli.MapSuccess, nil
}

24
dtmsvr/api_grpc.go

@ -33,26 +33,12 @@ func (s *dtmServer) Abort(ctx context.Context, in *pb.DtmRequest) (*emptypb.Empt
return &emptypb.Empty{}, dtmgimp.Result2Error(r, err)
}
func (s *dtmServer) RegisterTccBranch(ctx context.Context, in *pb.DtmTccBranchRequest) (*emptypb.Empty, error) {
r, err := svcRegisterTccBranch(&TransBranch{
Gid: in.Info.Gid,
BranchID: in.Info.BranchID,
func (s *dtmServer) RegisterBranch(ctx context.Context, in *pb.DtmBranchRequest) (*emptypb.Empty, error) {
r, err := svcRegisterBranch(&TransBranch{
Gid: in.Gid,
BranchID: in.BranchID,
Status: dtmcli.StatusPrepared,
BinData: in.BusiPayload,
}, map[string]string{
dtmcli.BranchCancel: in.Cancel,
dtmcli.BranchConfirm: in.Confirm,
})
return &emptypb.Empty{}, dtmgimp.Result2Error(r, err)
}
func (s *dtmServer) RegisterXaBranch(ctx context.Context, in *pb.DtmXaBranchRequest) (*emptypb.Empty, error) {
r, err := svcRegisterXaBranch(&TransBranch{
Gid: in.Info.Gid,
BranchID: in.Info.BranchID,
Status: dtmcli.StatusPrepared,
BinData: in.BusiPayload,
URL: in.Notify,
})
}, in.Data)
return &emptypb.Empty{}, dtmgimp.Result2Error(r, err)
}

16
dtmsvr/api_http.go

@ -15,8 +15,9 @@ func addRoute(engine *gin.Engine) {
engine.POST("/api/dtmsvr/prepare", common.WrapHandler(prepare))
engine.POST("/api/dtmsvr/submit", common.WrapHandler(submit))
engine.POST("/api/dtmsvr/abort", common.WrapHandler(abort))
engine.POST("/api/dtmsvr/registerXaBranch", common.WrapHandler(registerXaBranch))
engine.POST("/api/dtmsvr/registerTccBranch", common.WrapHandler(registerTccBranch))
engine.POST("/api/dtmsvr/registerBranch", common.WrapHandler(registerBranch))
engine.POST("/api/dtmsvr/registerXaBranch", common.WrapHandler(registerBranch)) // compatible for old sdk
engine.POST("/api/dtmsvr/registerTccBranch", common.WrapHandler(registerBranch)) // compatible for old sdk
engine.GET("/api/dtmsvr/query", common.WrapHandler(query))
engine.GET("/api/dtmsvr/all", common.WrapHandler(all))
}
@ -37,14 +38,7 @@ func abort(c *gin.Context) (interface{}, error) {
return svcAbort(TransFromContext(c))
}
func registerXaBranch(c *gin.Context) (interface{}, error) {
branch := TransBranch{}
err := c.BindJSON(&branch)
e2p(err)
return svcRegisterXaBranch(&branch)
}
func registerTccBranch(c *gin.Context) (interface{}, error) {
func registerBranch(c *gin.Context) (interface{}, error) {
data := map[string]string{}
err := c.BindJSON(&data)
e2p(err)
@ -54,7 +48,7 @@ func registerTccBranch(c *gin.Context) (interface{}, error) {
Status: dtmcli.StatusPrepared,
BinData: []byte(data["data"]),
}
return svcRegisterTccBranch(&branch, data)
return svcRegisterBranch(&branch, data)
}
func query(c *gin.Context) (interface{}, error) {

Loading…
Cancel
Save