diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..2282245 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,45 @@ +name: Tests +on: + push: + branches-ignore: + - 'tmp-*' + pull_request: + branches-ignore: + - 'tmp-*' + +jobs: + tests: + name: CI + runs-on: ubuntu-latest + services: + mysql: + image: 'mysql:5.7' + env: + MYSQL_ALLOW_EMPTY_PASSWORD: 1 + volumes: + - /etc/localtime:/etc/localtime:ro + - /etc/timezone:/etc/timezone:ro + ports: + - 3306:3306 + reids: + image: 'redis' + volumes: + - /etc/localtime:/etc/localtime:ro + - /etc/timezone:/etc/timezone:ro + ports: + - 6379:6379 + steps: + - name: Set up Go 1.15 + uses: actions/setup-go@v2 + with: + go-version: '1.15' + + - name: Check out code + uses: actions/checkout@v2 + + - name: Install dependencies + run: | + go mod download + + - name: Run test cover + run: sh helper/test-cover.sh diff --git a/.gitignore b/.gitignore index ca6b347..771c69c 100644 --- a/.gitignore +++ b/.gitignore @@ -10,5 +10,6 @@ default.etcd */**/*.bolt # Output file of unit test coverage -coverage.out -coverage.out.tmp \ No newline at end of file +coverage.* +profile.* +test.sh \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 5fde38f..0000000 --- a/.travis.yml +++ /dev/null @@ -1,18 +0,0 @@ -language: go -go: - - 1.15.x -env: - - GO111MODULE=on -branches: - only: - - master - - main - - alpha -services: - - mysql - - redis-server -before_install: - - go get -t -v ./... - - go get github.com/yedf2/goveralls -script: - - $GOPATH/bin/goveralls -envs=TEST_STORE=redis,TEST_STORE=mysql,TEST_STORE=boltdb -flags '-gcflags=-l' -service=travis-ci -ignore="examples/*,dtmgrpc/dtmgimp/*.pb.go,bench/*,test/*" diff --git a/dtmgrpc/dtmgimp/grpc_clients.go b/dtmgrpc/dtmgimp/grpc_clients.go index 917f322..17c7b54 100644 --- a/dtmgrpc/dtmgimp/grpc_clients.go +++ b/dtmgrpc/dtmgimp/grpc_clients.go @@ -8,9 +8,11 @@ package dtmgimp import ( "fmt" + "sync" + "github.com/yedf/dtm/dtmcli/dtmimp" + "github.com/yedf/dtm/dtmgrpc/dtmgpb" grpc "google.golang.org/grpc" - "sync" ) type rawCodec struct{} @@ -33,13 +35,13 @@ func (cb rawCodec) Name() string { return "dtm_raw" } var normalClients, rawClients sync.Map // MustGetDtmClient 1 -func MustGetDtmClient(grpcServer string) DtmClient { - return NewDtmClient(MustGetGrpcConn(grpcServer, false)) +func MustGetDtmClient(grpcServer string) dtmgpb.DtmClient { + return dtmgpb.NewDtmClient(MustGetGrpcConn(grpcServer, false)) } // MustGetRawDtmClient must get raw codec grpc conn -func MustGetRawDtmClient(grpcServer string) DtmClient { - return NewDtmClient(MustGetGrpcConn(grpcServer, true)) +func MustGetRawDtmClient(grpcServer string) dtmgpb.DtmClient { + return dtmgpb.NewDtmClient(MustGetGrpcConn(grpcServer, true)) } // GetGrpcConn 1 diff --git a/dtmgrpc/dtmgimp/utils.go b/dtmgrpc/dtmgimp/utils.go index ba2e08e..357d0c7 100644 --- a/dtmgrpc/dtmgimp/utils.go +++ b/dtmgrpc/dtmgimp/utils.go @@ -10,6 +10,7 @@ import ( context "context" "github.com/yedf/dtm/dtmcli/dtmimp" + "github.com/yedf/dtm/dtmgrpc/dtmgpb" "google.golang.org/grpc/metadata" "google.golang.org/protobuf/proto" emptypb "google.golang.org/protobuf/types/known/emptypb" @@ -25,10 +26,10 @@ func MustProtoMarshal(msg proto.Message) []byte { // DtmGrpcCall make a convenient call to dtm func DtmGrpcCall(s *dtmimp.TransBase, operation string) error { reply := emptypb.Empty{} - return MustGetGrpcConn(s.Dtm, false).Invoke(context.Background(), "/dtmgimp.Dtm/"+operation, &DtmRequest{ + return MustGetGrpcConn(s.Dtm, false).Invoke(context.Background(), "/dtmgimp.Dtm/"+operation, &dtmgpb.DtmRequest{ Gid: s.Gid, TransType: s.TransType, - TransOptions: &DtmTransOptions{ + TransOptions: &dtmgpb.DtmTransOptions{ WaitResult: s.WaitResult, TimeoutToFail: s.TimeoutToFail, RetryInterval: s.RetryInterval, diff --git a/dtmgrpc/dtmgimp/dtmgimp.pb.go b/dtmgrpc/dtmgpb/dtmgimp.pb.go similarity index 54% rename from dtmgrpc/dtmgimp/dtmgimp.pb.go rename to dtmgrpc/dtmgpb/dtmgimp.pb.go index 3b28c14..89a2526 100644 --- a/dtmgrpc/dtmgimp/dtmgimp.pb.go +++ b/dtmgrpc/dtmgpb/dtmgimp.pb.go @@ -1,16 +1,10 @@ -/* - * Copyright (c) 2021 yedf. All rights reserved. - * Use of this source code is governed by a BSD-style - * license that can be found in the LICENSE file. - */ - // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.27.1 // protoc v3.17.3 -// source: dtmgrpc/dtmgimp/dtmgimp.proto +// source: dtmgrpc/dtmgpb/dtmgimp.proto -package dtmgimp +package dtmgpb import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" @@ -40,7 +34,7 @@ type DtmTransOptions struct { func (x *DtmTransOptions) Reset() { *x = DtmTransOptions{} if protoimpl.UnsafeEnabled { - mi := &file_dtmgrpc_dtmgimp_dtmgimp_proto_msgTypes[0] + mi := &file_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -53,7 +47,7 @@ func (x *DtmTransOptions) String() string { func (*DtmTransOptions) ProtoMessage() {} func (x *DtmTransOptions) ProtoReflect() protoreflect.Message { - mi := &file_dtmgrpc_dtmgimp_dtmgimp_proto_msgTypes[0] + mi := &file_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -66,7 +60,7 @@ func (x *DtmTransOptions) ProtoReflect() protoreflect.Message { // Deprecated: Use DtmTransOptions.ProtoReflect.Descriptor instead. func (*DtmTransOptions) Descriptor() ([]byte, []int) { - return file_dtmgrpc_dtmgimp_dtmgimp_proto_rawDescGZIP(), []int{0} + return file_dtmgrpc_dtmgpb_dtmgimp_proto_rawDescGZIP(), []int{0} } func (x *DtmTransOptions) GetWaitResult() bool { @@ -108,7 +102,7 @@ type DtmRequest struct { func (x *DtmRequest) Reset() { *x = DtmRequest{} if protoimpl.UnsafeEnabled { - mi := &file_dtmgrpc_dtmgimp_dtmgimp_proto_msgTypes[1] + mi := &file_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -121,7 +115,7 @@ func (x *DtmRequest) String() string { func (*DtmRequest) ProtoMessage() {} func (x *DtmRequest) ProtoReflect() protoreflect.Message { - mi := &file_dtmgrpc_dtmgimp_dtmgimp_proto_msgTypes[1] + mi := &file_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -134,7 +128,7 @@ func (x *DtmRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use DtmRequest.ProtoReflect.Descriptor instead. func (*DtmRequest) Descriptor() ([]byte, []int) { - return file_dtmgrpc_dtmgimp_dtmgimp_proto_rawDescGZIP(), []int{1} + return file_dtmgrpc_dtmgpb_dtmgimp_proto_rawDescGZIP(), []int{1} } func (x *DtmRequest) GetGid() string { @@ -197,7 +191,7 @@ type DtmGidReply struct { func (x *DtmGidReply) Reset() { *x = DtmGidReply{} if protoimpl.UnsafeEnabled { - mi := &file_dtmgrpc_dtmgimp_dtmgimp_proto_msgTypes[2] + mi := &file_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -210,7 +204,7 @@ func (x *DtmGidReply) String() string { func (*DtmGidReply) ProtoMessage() {} func (x *DtmGidReply) ProtoReflect() protoreflect.Message { - mi := &file_dtmgrpc_dtmgimp_dtmgimp_proto_msgTypes[2] + mi := &file_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -223,7 +217,7 @@ func (x *DtmGidReply) ProtoReflect() protoreflect.Message { // Deprecated: Use DtmGidReply.ProtoReflect.Descriptor instead. func (*DtmGidReply) Descriptor() ([]byte, []int) { - return file_dtmgrpc_dtmgimp_dtmgimp_proto_rawDescGZIP(), []int{2} + return file_dtmgrpc_dtmgpb_dtmgimp_proto_rawDescGZIP(), []int{2} } func (x *DtmGidReply) GetGid() string { @@ -249,7 +243,7 @@ type DtmBranchRequest struct { func (x *DtmBranchRequest) Reset() { *x = DtmBranchRequest{} if protoimpl.UnsafeEnabled { - mi := &file_dtmgrpc_dtmgimp_dtmgimp_proto_msgTypes[3] + mi := &file_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -262,7 +256,7 @@ func (x *DtmBranchRequest) String() string { func (*DtmBranchRequest) ProtoMessage() {} func (x *DtmBranchRequest) ProtoReflect() protoreflect.Message { - mi := &file_dtmgrpc_dtmgimp_dtmgimp_proto_msgTypes[3] + mi := &file_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -275,7 +269,7 @@ func (x *DtmBranchRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use DtmBranchRequest.ProtoReflect.Descriptor instead. func (*DtmBranchRequest) Descriptor() ([]byte, []int) { - return file_dtmgrpc_dtmgimp_dtmgimp_proto_rawDescGZIP(), []int{3} + return file_dtmgrpc_dtmgpb_dtmgimp_proto_rawDescGZIP(), []int{3} } func (x *DtmBranchRequest) GetGid() string { @@ -320,93 +314,92 @@ func (x *DtmBranchRequest) GetBusiPayload() []byte { return nil } -var File_dtmgrpc_dtmgimp_dtmgimp_proto protoreflect.FileDescriptor - -var file_dtmgrpc_dtmgimp_dtmgimp_proto_rawDesc = []byte{ - 0x0a, 0x1d, 0x64, 0x74, 0x6d, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x64, 0x74, 0x6d, 0x67, 0x69, 0x6d, - 0x70, 0x2f, 0x64, 0x74, 0x6d, 0x67, 0x69, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, - 0x07, 0x64, 0x74, 0x6d, 0x67, 0x69, 0x6d, 0x70, 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, 0x7d, 0x0a, 0x0f, 0x44, 0x74, 0x6d, 0x54, 0x72, 0x61, 0x6e, - 0x73, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x57, 0x61, 0x69, 0x74, - 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x57, 0x61, - 0x69, 0x74, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x24, 0x0a, 0x0d, 0x54, 0x69, 0x6d, 0x65, - 0x6f, 0x75, 0x74, 0x54, 0x6f, 0x46, 0x61, 0x69, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x0d, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x54, 0x6f, 0x46, 0x61, 0x69, 0x6c, 0x12, 0x24, - 0x0a, 0x0d, 0x52, 0x65, 0x74, 0x72, 0x79, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x52, 0x65, 0x74, 0x72, 0x79, 0x49, 0x6e, 0x74, 0x65, - 0x72, 0x76, 0x61, 0x6c, 0x22, 0xfc, 0x01, 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, 0x3c, 0x0a, 0x0c, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x4f, 0x70, 0x74, 0x69, - 0x6f, 0x6e, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x64, 0x74, 0x6d, 0x67, - 0x69, 0x6d, 0x70, 0x2e, 0x44, 0x74, 0x6d, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x4f, 0x70, 0x74, 0x69, - 0x6f, 0x6e, 0x73, 0x52, 0x0c, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, - 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65, 0x64, 0x44, 0x61, 0x74, - 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65, - 0x64, 0x44, 0x61, 0x74, 0x61, 0x12, 0x20, 0x0a, 0x0b, 0x42, 0x69, 0x6e, 0x50, 0x61, 0x79, 0x6c, - 0x6f, 0x61, 0x64, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x0b, 0x42, 0x69, 0x6e, 0x50, - 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x73, 0x12, 0x24, 0x0a, 0x0d, 0x51, 0x75, 0x65, 0x72, 0x79, - 0x50, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, - 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x64, 0x12, 0x14, 0x0a, - 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, 0x82, 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, 0x0e, 0x0a, 0x02, 0x4f, 0x70, 0x18, 0x04, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x02, 0x4f, 0x70, 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, +var File_dtmgrpc_dtmgpb_dtmgimp_proto protoreflect.FileDescriptor + +var file_dtmgrpc_dtmgpb_dtmgimp_proto_rawDesc = []byte{ + 0x0a, 0x1c, 0x64, 0x74, 0x6d, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x64, 0x74, 0x6d, 0x67, 0x70, 0x62, + 0x2f, 0x64, 0x74, 0x6d, 0x67, 0x69, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07, + 0x64, 0x74, 0x6d, 0x67, 0x69, 0x6d, 0x70, 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, 0x7d, 0x0a, 0x0f, 0x44, 0x74, 0x6d, 0x54, 0x72, 0x61, 0x6e, 0x73, + 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x57, 0x61, 0x69, 0x74, 0x52, + 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x57, 0x61, 0x69, + 0x74, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x24, 0x0a, 0x0d, 0x54, 0x69, 0x6d, 0x65, 0x6f, + 0x75, 0x74, 0x54, 0x6f, 0x46, 0x61, 0x69, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, + 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x54, 0x6f, 0x46, 0x61, 0x69, 0x6c, 0x12, 0x24, 0x0a, + 0x0d, 0x52, 0x65, 0x74, 0x72, 0x79, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x52, 0x65, 0x74, 0x72, 0x79, 0x49, 0x6e, 0x74, 0x65, 0x72, + 0x76, 0x61, 0x6c, 0x22, 0xfc, 0x01, 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, 0x3c, 0x0a, 0x0c, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x4f, 0x70, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x64, 0x74, 0x6d, 0x67, 0x69, + 0x6d, 0x70, 0x2e, 0x44, 0x74, 0x6d, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x4f, 0x70, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x52, 0x0c, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x12, 0x22, 0x0a, 0x0c, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65, 0x64, 0x44, 0x61, 0x74, 0x61, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65, 0x64, + 0x44, 0x61, 0x74, 0x61, 0x12, 0x20, 0x0a, 0x0b, 0x42, 0x69, 0x6e, 0x50, 0x61, 0x79, 0x6c, 0x6f, + 0x61, 0x64, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x0b, 0x42, 0x69, 0x6e, 0x50, 0x61, + 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x73, 0x12, 0x24, 0x0a, 0x0d, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, + 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x51, + 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x64, 0x12, 0x14, 0x0a, 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, 0x82, 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, 0x0e, 0x0a, 0x02, 0x4f, 0x70, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x02, 0x4f, 0x70, 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, 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, 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, + 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, 0x42, 0x0b, 0x5a, - 0x09, 0x2e, 0x2f, 0x64, 0x74, 0x6d, 0x67, 0x69, 0x6d, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 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, 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, 0x0a, 0x5a, 0x08, + 0x2e, 0x2f, 0x64, 0x74, 0x6d, 0x67, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( - file_dtmgrpc_dtmgimp_dtmgimp_proto_rawDescOnce sync.Once - file_dtmgrpc_dtmgimp_dtmgimp_proto_rawDescData = file_dtmgrpc_dtmgimp_dtmgimp_proto_rawDesc + file_dtmgrpc_dtmgpb_dtmgimp_proto_rawDescOnce sync.Once + file_dtmgrpc_dtmgpb_dtmgimp_proto_rawDescData = file_dtmgrpc_dtmgpb_dtmgimp_proto_rawDesc ) -func file_dtmgrpc_dtmgimp_dtmgimp_proto_rawDescGZIP() []byte { - file_dtmgrpc_dtmgimp_dtmgimp_proto_rawDescOnce.Do(func() { - file_dtmgrpc_dtmgimp_dtmgimp_proto_rawDescData = protoimpl.X.CompressGZIP(file_dtmgrpc_dtmgimp_dtmgimp_proto_rawDescData) +func file_dtmgrpc_dtmgpb_dtmgimp_proto_rawDescGZIP() []byte { + file_dtmgrpc_dtmgpb_dtmgimp_proto_rawDescOnce.Do(func() { + file_dtmgrpc_dtmgpb_dtmgimp_proto_rawDescData = protoimpl.X.CompressGZIP(file_dtmgrpc_dtmgpb_dtmgimp_proto_rawDescData) }) - return file_dtmgrpc_dtmgimp_dtmgimp_proto_rawDescData + return file_dtmgrpc_dtmgpb_dtmgimp_proto_rawDescData } -var file_dtmgrpc_dtmgimp_dtmgimp_proto_msgTypes = make([]protoimpl.MessageInfo, 5) -var file_dtmgrpc_dtmgimp_dtmgimp_proto_goTypes = []interface{}{ +var file_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_dtmgrpc_dtmgpb_dtmgimp_proto_goTypes = []interface{}{ (*DtmTransOptions)(nil), // 0: dtmgimp.DtmTransOptions (*DtmRequest)(nil), // 1: dtmgimp.DtmRequest (*DtmGidReply)(nil), // 2: dtmgimp.DtmGidReply @@ -414,7 +407,7 @@ var file_dtmgrpc_dtmgimp_dtmgimp_proto_goTypes = []interface{}{ nil, // 4: dtmgimp.DtmBranchRequest.DataEntry (*emptypb.Empty)(nil), // 5: google.protobuf.Empty } -var file_dtmgrpc_dtmgimp_dtmgimp_proto_depIdxs = []int32{ +var file_dtmgrpc_dtmgpb_dtmgimp_proto_depIdxs = []int32{ 0, // 0: dtmgimp.DtmRequest.TransOptions:type_name -> dtmgimp.DtmTransOptions 4, // 1: dtmgimp.DtmBranchRequest.Data:type_name -> dtmgimp.DtmBranchRequest.DataEntry 5, // 2: dtmgimp.Dtm.NewGid:input_type -> google.protobuf.Empty @@ -434,13 +427,13 @@ var file_dtmgrpc_dtmgimp_dtmgimp_proto_depIdxs = []int32{ 0, // [0:2] is the sub-list for field type_name } -func init() { file_dtmgrpc_dtmgimp_dtmgimp_proto_init() } -func file_dtmgrpc_dtmgimp_dtmgimp_proto_init() { - if File_dtmgrpc_dtmgimp_dtmgimp_proto != nil { +func init() { file_dtmgrpc_dtmgpb_dtmgimp_proto_init() } +func file_dtmgrpc_dtmgpb_dtmgimp_proto_init() { + if File_dtmgrpc_dtmgpb_dtmgimp_proto != nil { return } if !protoimpl.UnsafeEnabled { - file_dtmgrpc_dtmgimp_dtmgimp_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*DtmTransOptions); i { case 0: return &v.state @@ -452,7 +445,7 @@ func file_dtmgrpc_dtmgimp_dtmgimp_proto_init() { return nil } } - file_dtmgrpc_dtmgimp_dtmgimp_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*DtmRequest); i { case 0: return &v.state @@ -464,7 +457,7 @@ func file_dtmgrpc_dtmgimp_dtmgimp_proto_init() { return nil } } - file_dtmgrpc_dtmgimp_dtmgimp_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*DtmGidReply); i { case 0: return &v.state @@ -476,7 +469,7 @@ func file_dtmgrpc_dtmgimp_dtmgimp_proto_init() { return nil } } - file_dtmgrpc_dtmgimp_dtmgimp_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*DtmBranchRequest); i { case 0: return &v.state @@ -493,18 +486,18 @@ func file_dtmgrpc_dtmgimp_dtmgimp_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_dtmgrpc_dtmgimp_dtmgimp_proto_rawDesc, + RawDescriptor: file_dtmgrpc_dtmgpb_dtmgimp_proto_rawDesc, NumEnums: 0, NumMessages: 5, NumExtensions: 0, NumServices: 1, }, - GoTypes: file_dtmgrpc_dtmgimp_dtmgimp_proto_goTypes, - DependencyIndexes: file_dtmgrpc_dtmgimp_dtmgimp_proto_depIdxs, - MessageInfos: file_dtmgrpc_dtmgimp_dtmgimp_proto_msgTypes, + GoTypes: file_dtmgrpc_dtmgpb_dtmgimp_proto_goTypes, + DependencyIndexes: file_dtmgrpc_dtmgpb_dtmgimp_proto_depIdxs, + MessageInfos: file_dtmgrpc_dtmgpb_dtmgimp_proto_msgTypes, }.Build() - File_dtmgrpc_dtmgimp_dtmgimp_proto = out.File - file_dtmgrpc_dtmgimp_dtmgimp_proto_rawDesc = nil - file_dtmgrpc_dtmgimp_dtmgimp_proto_goTypes = nil - file_dtmgrpc_dtmgimp_dtmgimp_proto_depIdxs = nil + File_dtmgrpc_dtmgpb_dtmgimp_proto = out.File + file_dtmgrpc_dtmgpb_dtmgimp_proto_rawDesc = nil + file_dtmgrpc_dtmgpb_dtmgimp_proto_goTypes = nil + file_dtmgrpc_dtmgpb_dtmgimp_proto_depIdxs = nil } diff --git a/dtmgrpc/dtmgimp/dtmgimp.proto b/dtmgrpc/dtmgpb/dtmgimp.proto similarity index 96% rename from dtmgrpc/dtmgimp/dtmgimp.proto rename to dtmgrpc/dtmgpb/dtmgimp.proto index a6ef5e6..84e3105 100644 --- a/dtmgrpc/dtmgimp/dtmgimp.proto +++ b/dtmgrpc/dtmgpb/dtmgimp.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -option go_package = "./dtmgimp"; +option go_package = "./dtmgpb"; import "google/protobuf/empty.proto"; package dtmgimp; diff --git a/dtmgrpc/dtmgimp/dtmgimp_grpc.pb.go b/dtmgrpc/dtmgpb/dtmgimp_grpc.pb.go similarity index 97% rename from dtmgrpc/dtmgimp/dtmgimp_grpc.pb.go rename to dtmgrpc/dtmgpb/dtmgimp_grpc.pb.go index 8d35989..8381443 100644 --- a/dtmgrpc/dtmgimp/dtmgimp_grpc.pb.go +++ b/dtmgrpc/dtmgpb/dtmgimp_grpc.pb.go @@ -1,12 +1,6 @@ -/* - * Copyright (c) 2021 yedf. All rights reserved. - * Use of this source code is governed by a BSD-style - * license that can be found in the LICENSE file. - */ - // Code generated by protoc-gen-go-grpc. DO NOT EDIT. -package dtmgimp +package dtmgpb import ( context "context" @@ -248,5 +242,5 @@ var Dtm_ServiceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "dtmgrpc/dtmgimp/dtmgimp.proto", + Metadata: "dtmgrpc/dtmgpb/dtmgimp.proto", } diff --git a/dtmgrpc/tcc.go b/dtmgrpc/tcc.go index ebc1c59..1b8bebd 100644 --- a/dtmgrpc/tcc.go +++ b/dtmgrpc/tcc.go @@ -12,6 +12,7 @@ import ( "github.com/yedf/dtm/dtmcli/dtmimp" "github.com/yedf/dtm/dtmgrpc/dtmgimp" + "github.com/yedf/dtm/dtmgrpc/dtmgpb" "github.com/yedf/dtmdriver" "google.golang.org/protobuf/proto" ) @@ -31,7 +32,7 @@ type TccGlobalFunc func(tcc *TccGrpc) error func TccGlobalTransaction(dtm string, gid string, tccFunc TccGlobalFunc) (rerr error) { tcc := &TccGrpc{TransBase: *dtmimp.NewTransBase(gid, "tcc", dtm, "")} dc := dtmgimp.MustGetDtmClient(tcc.Dtm) - dr := &dtmgimp.DtmRequest{ + dr := &dtmgpb.DtmRequest{ Gid: tcc.Gid, TransType: tcc.TransType, } @@ -72,7 +73,7 @@ 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).RegisterBranch(context.Background(), &dtmgimp.DtmBranchRequest{ + _, err = dtmgimp.MustGetDtmClient(t.Dtm).RegisterBranch(context.Background(), &dtmgpb.DtmBranchRequest{ Gid: t.Gid, TransType: t.TransType, BranchID: branchID, diff --git a/dtmgrpc/xa.go b/dtmgrpc/xa.go index c12a7e6..23ba33c 100644 --- a/dtmgrpc/xa.go +++ b/dtmgrpc/xa.go @@ -14,6 +14,7 @@ import ( "github.com/yedf/dtm/dtmcli" "github.com/yedf/dtm/dtmcli/dtmimp" "github.com/yedf/dtm/dtmgrpc/dtmgimp" + "github.com/yedf/dtm/dtmgrpc/dtmgpb" "github.com/yedf/dtmdriver" grpc "google.golang.org/grpc" "google.golang.org/protobuf/proto" @@ -78,7 +79,7 @@ func (xc *XaGrpcClient) XaLocalTransaction(ctx context.Context, msg proto.Messag if err != nil { return err } - _, err = dtmgimp.MustGetDtmClient(xa.Dtm).RegisterBranch(context.Background(), &dtmgimp.DtmBranchRequest{ + _, err = dtmgimp.MustGetDtmClient(xa.Dtm).RegisterBranch(context.Background(), &dtmgpb.DtmBranchRequest{ Gid: xa.Gid, BranchID: xa.BranchID, TransType: xa.TransType, @@ -93,12 +94,12 @@ func (xc *XaGrpcClient) XaLocalTransaction(ctx context.Context, msg proto.Messag func (xc *XaGrpcClient) XaGlobalTransaction(gid string, xaFunc XaGrpcGlobalFunc) error { xa := XaGrpc{TransBase: *dtmimp.NewTransBase(gid, "xa", xc.Server, "")} dc := dtmgimp.MustGetDtmClient(xa.Dtm) - req := &dtmgimp.DtmRequest{ + req := &dtmgpb.DtmRequest{ Gid: gid, TransType: xa.TransType, } return xc.HandleGlobalTrans(&xa.TransBase, func(action string) error { - f := map[string]func(context.Context, *dtmgimp.DtmRequest, ...grpc.CallOption) (*emptypb.Empty, error){ + f := map[string]func(context.Context, *dtmgpb.DtmRequest, ...grpc.CallOption) (*emptypb.Empty, error){ "prepare": dc.Prepare, "submit": dc.Submit, "abort": dc.Abort, diff --git a/dtmsvr/api_grpc.go b/dtmsvr/api_grpc.go index 07e4d0e..4d4daf8 100644 --- a/dtmsvr/api_grpc.go +++ b/dtmsvr/api_grpc.go @@ -11,7 +11,7 @@ import ( "github.com/yedf/dtm/dtmcli" "github.com/yedf/dtm/dtmgrpc/dtmgimp" - pb "github.com/yedf/dtm/dtmgrpc/dtmgimp" + pb "github.com/yedf/dtm/dtmgrpc/dtmgpb" "google.golang.org/protobuf/types/known/emptypb" ) @@ -20,8 +20,8 @@ type dtmServer struct { pb.UnimplementedDtmServer } -func (s *dtmServer) NewGid(ctx context.Context, in *emptypb.Empty) (*dtmgimp.DtmGidReply, error) { - return &dtmgimp.DtmGidReply{Gid: GenGid()}, nil +func (s *dtmServer) NewGid(ctx context.Context, in *emptypb.Empty) (*pb.DtmGidReply, error) { + return &pb.DtmGidReply{Gid: GenGid()}, nil } func (s *dtmServer) Submit(ctx context.Context, in *pb.DtmRequest) (*emptypb.Empty, error) { diff --git a/dtmsvr/svr.go b/dtmsvr/svr.go index af92105..ac0dbf2 100644 --- a/dtmsvr/svr.go +++ b/dtmsvr/svr.go @@ -15,6 +15,7 @@ import ( "github.com/yedf/dtm/common" "github.com/yedf/dtm/dtmcli/dtmimp" "github.com/yedf/dtm/dtmgrpc/dtmgimp" + "github.com/yedf/dtm/dtmgrpc/dtmgpb" "github.com/yedf/dtmdriver" "google.golang.org/grpc" ) @@ -34,7 +35,7 @@ func StartSvr() { grpc.UnaryInterceptor(grpc_middleware.ChainUnaryServer( grpc.UnaryServerInterceptor(grpcMetrics), grpc.UnaryServerInterceptor(dtmgimp.GrpcServerLog)), )) - dtmgimp.RegisterDtmServer(s, &dtmServer{}) + dtmgpb.RegisterDtmServer(s, &dtmServer{}) dtmimp.Logf("grpc listening at %v", lis.Addr()) go func() { err := s.Serve(lis) diff --git a/dtmsvr/trans_class.go b/dtmsvr/trans_class.go index 4ce6b9e..d8ea01b 100644 --- a/dtmsvr/trans_class.go +++ b/dtmsvr/trans_class.go @@ -12,7 +12,7 @@ import ( "github.com/gin-gonic/gin" "github.com/yedf/dtm/dtmcli" "github.com/yedf/dtm/dtmcli/dtmimp" - "github.com/yedf/dtm/dtmgrpc/dtmgimp" + "github.com/yedf/dtm/dtmgrpc/dtmgpb" "github.com/yedf/dtm/dtmsvr/storage" ) @@ -72,8 +72,8 @@ func TransFromContext(c *gin.Context) *TransGlobal { } // TransFromDtmRequest TransFromContext -func TransFromDtmRequest(c *dtmgimp.DtmRequest) *TransGlobal { - o := &dtmgimp.DtmTransOptions{} +func TransFromDtmRequest(c *dtmgpb.DtmRequest) *TransGlobal { + o := &dtmgpb.DtmTransOptions{} if c.TransOptions != nil { o = c.TransOptions } diff --git a/examples/base_grpc.go b/examples/base_grpc.go index d0002b4..3bff6a5 100644 --- a/examples/base_grpc.go +++ b/examples/base_grpc.go @@ -19,6 +19,7 @@ import ( "github.com/yedf/dtm/dtmgrpc" "github.com/yedf/dtm/dtmgrpc/dtmgimp" + "github.com/yedf/dtm/dtmgrpc/dtmgpb" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -29,7 +30,7 @@ import ( var BusiGrpc string = fmt.Sprintf("localhost:%d", BusiGrpcPort) // DtmClient grpc client for dtm -var DtmClient dtmgimp.DtmClient = nil +var DtmClient dtmgpb.DtmClient = nil // XaGrpcClient XA client connection var XaGrpcClient *dtmgrpc.XaGrpcClient = nil @@ -44,7 +45,7 @@ func init() { func GrpcStartup() { conn, err := grpc.Dial(DtmGrpcServer, grpc.WithInsecure(), grpc.WithUnaryInterceptor(dtmgimp.GrpcClientLog)) dtmimp.FatalIfError(err) - DtmClient = dtmgimp.NewDtmClient(conn) + DtmClient = dtmgpb.NewDtmClient(conn) dtmimp.Logf("dtm client inited") lis, err := net.Listen("tcp", fmt.Sprintf(":%d", BusiGrpcPort)) diff --git a/go.sum b/go.sum index 6d8821e..a652bd4 100644 --- a/go.sum +++ b/go.sum @@ -892,3 +892,4 @@ sigs.k8s.io/structured-merge-diff/v4 v4.1.2/go.mod h1:j/nl6xW8vLS49O8YvXW1ocPhZa sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q= sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= + diff --git a/helper/test-cover.sh b/helper/test-cover.sh new file mode 100644 index 0000000..0bf9fbe --- /dev/null +++ b/helper/test-cover.sh @@ -0,0 +1,13 @@ +set -x +echo "" > coverage.txt +for store in redis mysql boltdb; do + for d in $(go list ./... | grep -v vendor); do + TEST_STORE=$store go test -covermode count -coverprofile=profile.out -coverpkg=github.com/yedf/dtm/common,github.com/yedf/dtm/dtmcli,github.com/yedf/dtm/dtmcli/dtmimp,github.com/yedf/dtm/dtmgrpc,github.com/yedf/dtm/dtmgrpc/dtmgimp,github.com/yedf/dtm/dtmsvr,github.com/yedf/dtm/dtmsvr/storage,github.com/yedf/dtm/dtmsvr/storage/boltdb,github.com/yedf/dtm/dtmsvr/storage/registry -gcflags=-l $d + if [ -f profile.out ]; then + cat profile.out >> coverage.txt + echo > profile.out + fi + done +done + +curl -s https://codecov.io/bash | bash