From 153fd442744d82a93320e60c905e59f30c6caf2a Mon Sep 17 00:00:00 2001 From: liulei Date: Thu, 24 Feb 2022 12:57:20 +0800 Subject: [PATCH] test: add test for grpc request support request timeout option --- test/busi/base_grpc.go | 4 ++ test/busi/busi.pb.go | 143 ++++++++++++++++++++------------------ test/busi/busi.proto | 1 + test/busi/busi_grpc.pb.go | 40 +++++++++++ test/saga_grpc_test.go | 11 +++ 5 files changed, 131 insertions(+), 68 deletions(-) diff --git a/test/busi/base_grpc.go b/test/busi/base_grpc.go index 682c37d..fe5d255 100644 --- a/test/busi/base_grpc.go +++ b/test/busi/base_grpc.go @@ -128,6 +128,10 @@ func (s *busiServer) XaNotify(ctx context.Context, in *emptypb.Empty) (*emptypb. return XaGrpcClient.HandleCallback(ctx) } +func (s *busiServer) TransOutWithGlobalRequestTimeout(ctx context.Context, in *BusiReq) (*emptypb.Empty, error) { + return &emptypb.Empty{}, handleGrpcBusiness(in, MainSwitch.TransOutResult.Fetch(), in.TransOutResult, dtmimp.GetFuncName()) +} + func (s *busiServer) TransOutHeaderYes(ctx context.Context, in *BusiReq) (*emptypb.Empty, error) { meta := dtmgimp.GetMetaFromContext(ctx, "test_header") if meta == "" { diff --git a/test/busi/busi.pb.go b/test/busi/busi.pb.go index 09b8d85..e9c31f6 100644 --- a/test/busi/busi.pb.go +++ b/test/busi/busi.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.27.1 -// protoc v3.17.3 +// protoc v3.19.4 // source: test/busi/busi.proto package busi @@ -148,7 +148,7 @@ var file_test_busi_busi_proto_rawDesc = []byte{ 0x6e, 0x73, 0x49, 0x6e, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x25, 0x0a, 0x09, 0x42, 0x75, 0x73, 0x69, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, - 0x65, 0x32, 0xbe, 0x0b, 0x0a, 0x04, 0x42, 0x75, 0x73, 0x69, 0x12, 0x32, 0x0a, 0x07, 0x54, 0x72, + 0x65, 0x32, 0x8b, 0x0c, 0x0a, 0x04, 0x42, 0x75, 0x73, 0x69, 0x12, 0x32, 0x0a, 0x07, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x49, 0x6e, 0x12, 0x0d, 0x2e, 0x62, 0x75, 0x73, 0x69, 0x2e, 0x42, 0x75, 0x73, 0x69, 0x52, 0x65, 0x71, 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, 0x33, @@ -206,42 +206,47 @@ var file_test_busi_busi_proto_rawDesc = []byte{ 0x73, 0x4f, 0x75, 0x74, 0x52, 0x65, 0x76, 0x65, 0x72, 0x74, 0x42, 0x53, 0x61, 0x67, 0x61, 0x12, 0x0d, 0x2e, 0x62, 0x75, 0x73, 0x69, 0x2e, 0x42, 0x75, 0x73, 0x69, 0x52, 0x65, 0x71, 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, 0x3c, 0x0a, 0x11, 0x54, 0x72, 0x61, 0x6e, - 0x73, 0x4f, 0x75, 0x74, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x59, 0x65, 0x73, 0x12, 0x0d, 0x2e, - 0x62, 0x75, 0x73, 0x69, 0x2e, 0x42, 0x75, 0x73, 0x69, 0x52, 0x65, 0x71, 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, 0x3b, 0x0a, 0x10, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x4f, - 0x75, 0x74, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x4e, 0x6f, 0x12, 0x0d, 0x2e, 0x62, 0x75, 0x73, - 0x69, 0x2e, 0x42, 0x75, 0x73, 0x69, 0x52, 0x65, 0x71, 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, 0x37, 0x0a, 0x0c, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x49, 0x6e, 0x52, 0x65, - 0x64, 0x69, 0x73, 0x12, 0x0d, 0x2e, 0x62, 0x75, 0x73, 0x69, 0x2e, 0x42, 0x75, 0x73, 0x69, 0x52, - 0x65, 0x71, 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, 0x0d, - 0x54, 0x72, 0x61, 0x6e, 0x73, 0x4f, 0x75, 0x74, 0x52, 0x65, 0x64, 0x69, 0x73, 0x12, 0x0d, 0x2e, - 0x62, 0x75, 0x73, 0x69, 0x2e, 0x42, 0x75, 0x73, 0x69, 0x52, 0x65, 0x71, 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, 0x12, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x49, - 0x6e, 0x52, 0x65, 0x76, 0x65, 0x72, 0x74, 0x52, 0x65, 0x64, 0x69, 0x73, 0x12, 0x0d, 0x2e, 0x62, - 0x75, 0x73, 0x69, 0x2e, 0x42, 0x75, 0x73, 0x69, 0x52, 0x65, 0x71, 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, 0x13, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x4f, 0x75, - 0x74, 0x52, 0x65, 0x76, 0x65, 0x72, 0x74, 0x52, 0x65, 0x64, 0x69, 0x73, 0x12, 0x0d, 0x2e, 0x62, + 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x4b, 0x0a, 0x20, 0x54, 0x72, 0x61, 0x6e, + 0x73, 0x4f, 0x75, 0x74, 0x57, 0x69, 0x74, 0x68, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x0d, 0x2e, 0x62, 0x75, 0x73, 0x69, 0x2e, 0x42, 0x75, 0x73, 0x69, 0x52, 0x65, 0x71, 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, 0x31, 0x0a, 0x0d, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, - 0x65, 0x70, 0x61, 0x72, 0x65, 0x64, 0x12, 0x0d, 0x2e, 0x62, 0x75, 0x73, 0x69, 0x2e, 0x42, 0x75, - 0x73, 0x69, 0x52, 0x65, 0x71, 0x1a, 0x0f, 0x2e, 0x62, 0x75, 0x73, 0x69, 0x2e, 0x42, 0x75, 0x73, - 0x69, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x39, 0x0a, 0x0e, 0x51, 0x75, 0x65, 0x72, - 0x79, 0x50, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x64, 0x42, 0x12, 0x0d, 0x2e, 0x62, 0x75, 0x73, + 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x3c, 0x0a, 0x11, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x4f, 0x75, + 0x74, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x59, 0x65, 0x73, 0x12, 0x0d, 0x2e, 0x62, 0x75, 0x73, 0x69, 0x2e, 0x42, 0x75, 0x73, 0x69, 0x52, 0x65, 0x71, 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, 0x12, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x65, 0x70, - 0x61, 0x72, 0x65, 0x64, 0x52, 0x65, 0x64, 0x69, 0x73, 0x12, 0x0d, 0x2e, 0x62, 0x75, 0x73, 0x69, + 0x79, 0x22, 0x00, 0x12, 0x3b, 0x0a, 0x10, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x4f, 0x75, 0x74, 0x48, + 0x65, 0x61, 0x64, 0x65, 0x72, 0x4e, 0x6f, 0x12, 0x0d, 0x2e, 0x62, 0x75, 0x73, 0x69, 0x2e, 0x42, + 0x75, 0x73, 0x69, 0x52, 0x65, 0x71, 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, 0x37, 0x0a, 0x0c, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x49, 0x6e, 0x52, 0x65, 0x64, 0x69, 0x73, + 0x12, 0x0d, 0x2e, 0x62, 0x75, 0x73, 0x69, 0x2e, 0x42, 0x75, 0x73, 0x69, 0x52, 0x65, 0x71, 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, 0x0d, 0x54, 0x72, 0x61, + 0x6e, 0x73, 0x4f, 0x75, 0x74, 0x52, 0x65, 0x64, 0x69, 0x73, 0x12, 0x0d, 0x2e, 0x62, 0x75, 0x73, + 0x69, 0x2e, 0x42, 0x75, 0x73, 0x69, 0x52, 0x65, 0x71, 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, 0x12, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x49, 0x6e, 0x52, 0x65, + 0x76, 0x65, 0x72, 0x74, 0x52, 0x65, 0x64, 0x69, 0x73, 0x12, 0x0d, 0x2e, 0x62, 0x75, 0x73, 0x69, 0x2e, 0x42, 0x75, 0x73, 0x69, 0x52, 0x65, 0x71, 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, 0x08, 0x5a, 0x06, 0x2e, 0x2f, 0x62, 0x75, 0x73, 0x69, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x13, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x4f, 0x75, 0x74, 0x52, 0x65, + 0x76, 0x65, 0x72, 0x74, 0x52, 0x65, 0x64, 0x69, 0x73, 0x12, 0x0d, 0x2e, 0x62, 0x75, 0x73, 0x69, + 0x2e, 0x42, 0x75, 0x73, 0x69, 0x52, 0x65, 0x71, 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, 0x31, 0x0a, 0x0d, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x65, 0x70, 0x61, + 0x72, 0x65, 0x64, 0x12, 0x0d, 0x2e, 0x62, 0x75, 0x73, 0x69, 0x2e, 0x42, 0x75, 0x73, 0x69, 0x52, + 0x65, 0x71, 0x1a, 0x0f, 0x2e, 0x62, 0x75, 0x73, 0x69, 0x2e, 0x42, 0x75, 0x73, 0x69, 0x52, 0x65, + 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x39, 0x0a, 0x0e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, + 0x65, 0x70, 0x61, 0x72, 0x65, 0x64, 0x42, 0x12, 0x0d, 0x2e, 0x62, 0x75, 0x73, 0x69, 0x2e, 0x42, + 0x75, 0x73, 0x69, 0x52, 0x65, 0x71, 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, 0x12, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, + 0x64, 0x52, 0x65, 0x64, 0x69, 0x73, 0x12, 0x0d, 0x2e, 0x62, 0x75, 0x73, 0x69, 0x2e, 0x42, 0x75, + 0x73, 0x69, 0x52, 0x65, 0x71, 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, + 0x08, 0x5a, 0x06, 0x2e, 0x2f, 0x62, 0x75, 0x73, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( @@ -279,42 +284,44 @@ var file_test_busi_busi_proto_depIdxs = []int32{ 0, // 13: busi.Busi.TransOutBSaga:input_type -> busi.BusiReq 0, // 14: busi.Busi.TransInRevertBSaga:input_type -> busi.BusiReq 0, // 15: busi.Busi.TransOutRevertBSaga:input_type -> busi.BusiReq - 0, // 16: busi.Busi.TransOutHeaderYes:input_type -> busi.BusiReq - 0, // 17: busi.Busi.TransOutHeaderNo:input_type -> busi.BusiReq - 0, // 18: busi.Busi.TransInRedis:input_type -> busi.BusiReq - 0, // 19: busi.Busi.TransOutRedis:input_type -> busi.BusiReq - 0, // 20: busi.Busi.TransInRevertRedis:input_type -> busi.BusiReq - 0, // 21: busi.Busi.TransOutRevertRedis:input_type -> busi.BusiReq - 0, // 22: busi.Busi.QueryPrepared:input_type -> busi.BusiReq - 0, // 23: busi.Busi.QueryPreparedB:input_type -> busi.BusiReq - 0, // 24: busi.Busi.QueryPreparedRedis:input_type -> busi.BusiReq - 2, // 25: busi.Busi.TransIn:output_type -> google.protobuf.Empty - 2, // 26: busi.Busi.TransOut:output_type -> google.protobuf.Empty - 2, // 27: busi.Busi.TransInRevert:output_type -> google.protobuf.Empty - 2, // 28: busi.Busi.TransOutRevert:output_type -> google.protobuf.Empty - 2, // 29: busi.Busi.TransInConfirm:output_type -> google.protobuf.Empty - 2, // 30: busi.Busi.TransOutConfirm:output_type -> google.protobuf.Empty - 2, // 31: busi.Busi.XaNotify:output_type -> google.protobuf.Empty - 2, // 32: busi.Busi.TransInXa:output_type -> google.protobuf.Empty - 2, // 33: busi.Busi.TransOutXa:output_type -> google.protobuf.Empty - 2, // 34: busi.Busi.TransInTcc:output_type -> google.protobuf.Empty - 2, // 35: busi.Busi.TransOutTcc:output_type -> google.protobuf.Empty - 2, // 36: busi.Busi.TransInTccNested:output_type -> google.protobuf.Empty - 2, // 37: busi.Busi.TransInBSaga:output_type -> google.protobuf.Empty - 2, // 38: busi.Busi.TransOutBSaga:output_type -> google.protobuf.Empty - 2, // 39: busi.Busi.TransInRevertBSaga:output_type -> google.protobuf.Empty - 2, // 40: busi.Busi.TransOutRevertBSaga:output_type -> google.protobuf.Empty - 2, // 41: busi.Busi.TransOutHeaderYes:output_type -> google.protobuf.Empty - 2, // 42: busi.Busi.TransOutHeaderNo:output_type -> google.protobuf.Empty - 2, // 43: busi.Busi.TransInRedis:output_type -> google.protobuf.Empty - 2, // 44: busi.Busi.TransOutRedis:output_type -> google.protobuf.Empty - 2, // 45: busi.Busi.TransInRevertRedis:output_type -> google.protobuf.Empty - 2, // 46: busi.Busi.TransOutRevertRedis:output_type -> google.protobuf.Empty - 1, // 47: busi.Busi.QueryPrepared:output_type -> busi.BusiReply - 2, // 48: busi.Busi.QueryPreparedB:output_type -> google.protobuf.Empty - 2, // 49: busi.Busi.QueryPreparedRedis:output_type -> google.protobuf.Empty - 25, // [25:50] is the sub-list for method output_type - 0, // [0:25] is the sub-list for method input_type + 0, // 16: busi.Busi.TransOutWithGlobalRequestTimeout:input_type -> busi.BusiReq + 0, // 17: busi.Busi.TransOutHeaderYes:input_type -> busi.BusiReq + 0, // 18: busi.Busi.TransOutHeaderNo:input_type -> busi.BusiReq + 0, // 19: busi.Busi.TransInRedis:input_type -> busi.BusiReq + 0, // 20: busi.Busi.TransOutRedis:input_type -> busi.BusiReq + 0, // 21: busi.Busi.TransInRevertRedis:input_type -> busi.BusiReq + 0, // 22: busi.Busi.TransOutRevertRedis:input_type -> busi.BusiReq + 0, // 23: busi.Busi.QueryPrepared:input_type -> busi.BusiReq + 0, // 24: busi.Busi.QueryPreparedB:input_type -> busi.BusiReq + 0, // 25: busi.Busi.QueryPreparedRedis:input_type -> busi.BusiReq + 2, // 26: busi.Busi.TransIn:output_type -> google.protobuf.Empty + 2, // 27: busi.Busi.TransOut:output_type -> google.protobuf.Empty + 2, // 28: busi.Busi.TransInRevert:output_type -> google.protobuf.Empty + 2, // 29: busi.Busi.TransOutRevert:output_type -> google.protobuf.Empty + 2, // 30: busi.Busi.TransInConfirm:output_type -> google.protobuf.Empty + 2, // 31: busi.Busi.TransOutConfirm:output_type -> google.protobuf.Empty + 2, // 32: busi.Busi.XaNotify:output_type -> google.protobuf.Empty + 2, // 33: busi.Busi.TransInXa:output_type -> google.protobuf.Empty + 2, // 34: busi.Busi.TransOutXa:output_type -> google.protobuf.Empty + 2, // 35: busi.Busi.TransInTcc:output_type -> google.protobuf.Empty + 2, // 36: busi.Busi.TransOutTcc:output_type -> google.protobuf.Empty + 2, // 37: busi.Busi.TransInTccNested:output_type -> google.protobuf.Empty + 2, // 38: busi.Busi.TransInBSaga:output_type -> google.protobuf.Empty + 2, // 39: busi.Busi.TransOutBSaga:output_type -> google.protobuf.Empty + 2, // 40: busi.Busi.TransInRevertBSaga:output_type -> google.protobuf.Empty + 2, // 41: busi.Busi.TransOutRevertBSaga:output_type -> google.protobuf.Empty + 2, // 42: busi.Busi.TransOutWithGlobalRequestTimeout:output_type -> google.protobuf.Empty + 2, // 43: busi.Busi.TransOutHeaderYes:output_type -> google.protobuf.Empty + 2, // 44: busi.Busi.TransOutHeaderNo:output_type -> google.protobuf.Empty + 2, // 45: busi.Busi.TransInRedis:output_type -> google.protobuf.Empty + 2, // 46: busi.Busi.TransOutRedis:output_type -> google.protobuf.Empty + 2, // 47: busi.Busi.TransInRevertRedis:output_type -> google.protobuf.Empty + 2, // 48: busi.Busi.TransOutRevertRedis:output_type -> google.protobuf.Empty + 1, // 49: busi.Busi.QueryPrepared:output_type -> busi.BusiReply + 2, // 50: busi.Busi.QueryPreparedB:output_type -> google.protobuf.Empty + 2, // 51: busi.Busi.QueryPreparedRedis:output_type -> google.protobuf.Empty + 26, // [26:52] is the sub-list for method output_type + 0, // [0:26] 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 diff --git a/test/busi/busi.proto b/test/busi/busi.proto index 72a92b6..3c5ecd9 100644 --- a/test/busi/busi.proto +++ b/test/busi/busi.proto @@ -35,6 +35,7 @@ service Busi { rpc TransOutBSaga(BusiReq) returns (google.protobuf.Empty) {} rpc TransInRevertBSaga(BusiReq) returns (google.protobuf.Empty) {} rpc TransOutRevertBSaga(BusiReq) returns (google.protobuf.Empty) {} + rpc TransOutWithGlobalRequestTimeout(BusiReq) returns (google.protobuf.Empty) {} rpc TransOutHeaderYes(BusiReq) returns (google.protobuf.Empty) {} rpc TransOutHeaderNo(BusiReq) returns (google.protobuf.Empty) {} diff --git a/test/busi/busi_grpc.pb.go b/test/busi/busi_grpc.pb.go index 9235453..6de70fc 100644 --- a/test/busi/busi_grpc.pb.go +++ b/test/busi/busi_grpc.pb.go @@ -1,4 +1,8 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.2.0 +// - protoc v3.19.4 +// source: test/busi/busi.proto package busi @@ -35,6 +39,7 @@ type BusiClient interface { TransOutBSaga(ctx context.Context, in *BusiReq, opts ...grpc.CallOption) (*emptypb.Empty, error) TransInRevertBSaga(ctx context.Context, in *BusiReq, opts ...grpc.CallOption) (*emptypb.Empty, error) TransOutRevertBSaga(ctx context.Context, in *BusiReq, opts ...grpc.CallOption) (*emptypb.Empty, error) + TransOutWithGlobalRequestTimeout(ctx context.Context, in *BusiReq, opts ...grpc.CallOption) (*emptypb.Empty, error) TransOutHeaderYes(ctx context.Context, in *BusiReq, opts ...grpc.CallOption) (*emptypb.Empty, error) TransOutHeaderNo(ctx context.Context, in *BusiReq, opts ...grpc.CallOption) (*emptypb.Empty, error) TransInRedis(ctx context.Context, in *BusiReq, opts ...grpc.CallOption) (*emptypb.Empty, error) @@ -198,6 +203,15 @@ func (c *busiClient) TransOutRevertBSaga(ctx context.Context, in *BusiReq, opts return out, nil } +func (c *busiClient) TransOutWithGlobalRequestTimeout(ctx context.Context, in *BusiReq, opts ...grpc.CallOption) (*emptypb.Empty, error) { + out := new(emptypb.Empty) + err := c.cc.Invoke(ctx, "/busi.Busi/TransOutWithGlobalRequestTimeout", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *busiClient) TransOutHeaderYes(ctx context.Context, in *BusiReq, opts ...grpc.CallOption) (*emptypb.Empty, error) { out := new(emptypb.Empty) err := c.cc.Invoke(ctx, "/busi.Busi/TransOutHeaderYes", in, out, opts...) @@ -299,6 +313,7 @@ type BusiServer interface { TransOutBSaga(context.Context, *BusiReq) (*emptypb.Empty, error) TransInRevertBSaga(context.Context, *BusiReq) (*emptypb.Empty, error) TransOutRevertBSaga(context.Context, *BusiReq) (*emptypb.Empty, error) + TransOutWithGlobalRequestTimeout(context.Context, *BusiReq) (*emptypb.Empty, error) TransOutHeaderYes(context.Context, *BusiReq) (*emptypb.Empty, error) TransOutHeaderNo(context.Context, *BusiReq) (*emptypb.Empty, error) TransInRedis(context.Context, *BusiReq) (*emptypb.Empty, error) @@ -363,6 +378,9 @@ func (UnimplementedBusiServer) TransInRevertBSaga(context.Context, *BusiReq) (*e func (UnimplementedBusiServer) TransOutRevertBSaga(context.Context, *BusiReq) (*emptypb.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method TransOutRevertBSaga not implemented") } +func (UnimplementedBusiServer) TransOutWithGlobalRequestTimeout(context.Context, *BusiReq) (*emptypb.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method TransOutWithGlobalRequestTimeout not implemented") +} func (UnimplementedBusiServer) TransOutHeaderYes(context.Context, *BusiReq) (*emptypb.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method TransOutHeaderYes not implemented") } @@ -691,6 +709,24 @@ func _Busi_TransOutRevertBSaga_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +func _Busi_TransOutWithGlobalRequestTimeout_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(BusiReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(BusiServer).TransOutWithGlobalRequestTimeout(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/busi.Busi/TransOutWithGlobalRequestTimeout", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(BusiServer).TransOutWithGlobalRequestTimeout(ctx, req.(*BusiReq)) + } + return interceptor(ctx, in, info, handler) +} + func _Busi_TransOutHeaderYes_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(BusiReq) if err := dec(in); err != nil { @@ -924,6 +960,10 @@ var Busi_ServiceDesc = grpc.ServiceDesc{ MethodName: "TransOutRevertBSaga", Handler: _Busi_TransOutRevertBSaga_Handler, }, + { + MethodName: "TransOutWithGlobalRequestTimeout", + Handler: _Busi_TransOutWithGlobalRequestTimeout_Handler, + }, { MethodName: "TransOutHeaderYes", Handler: _Busi_TransOutHeaderYes_Handler, diff --git a/test/saga_grpc_test.go b/test/saga_grpc_test.go index ee181ce..70fd731 100644 --- a/test/saga_grpc_test.go +++ b/test/saga_grpc_test.go @@ -110,6 +110,17 @@ func TestSagaGrpcPassthroughHeadersYes(t *testing.T) { waitTransProcessed(gidYes) } +func TestSagaGrpcWithGlobalTransRequestTimeout(t *testing.T) { + gid := dtmimp.GetFuncName() + saga := dtmgrpc.NewSagaGrpc(dtmutil.DefaultGrpcServer, gid) + saga.WaitResult = true + saga.Add(busi.BusiGrpc+"/busi.Busi/TransOutWithGlobalRequestTimeout", "", nil) + saga.WithGlobalTransRequestTimeout(6) + err := saga.Submit() + assert.Nil(t, err) + waitTransProcessed(gid) +} + func TestSagaGrpcCronPassthroughHeadersYes(t *testing.T) { gidYes := dtmimp.GetFuncName() sagaYes := dtmgrpc.NewSagaGrpc(dtmutil.DefaultGrpcServer, gidYes)