From a1ce79067989483e90c8da192d28d2c5f4f99f9d Mon Sep 17 00:00:00 2001 From: Rennbon <343688972@qq.com> Date: Tue, 8 Mar 2022 18:57:02 +0800 Subject: [PATCH] docs: TransOptions comment --- dtmcli/dtmimp/consts.go | 4 ++-- dtmcli/dtmimp/trans_base.go | 16 ++++++++-------- dtmsvr/api_http.go | 1 + 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/dtmcli/dtmimp/consts.go b/dtmcli/dtmimp/consts.go index 673289e..1061a9f 100644 --- a/dtmcli/dtmimp/consts.go +++ b/dtmcli/dtmimp/consts.go @@ -8,10 +8,10 @@ package dtmimp const ( // ResultFailure for result of a trans/trans branch - // Same as HTTP status 200 and GRPC code 0 + // Same as HTTP status 409 and GRPC code 10 ResultFailure = "FAILURE" // ResultSuccess for result of a trans/trans branch - // Same as HTTP status 409 and GRPC code 10 + // Same as HTTP status 200 and GRPC code 0 ResultSuccess = "SUCCESS" // ResultOngoing for result of a trans/trans branch // Same as HTTP status 425 and GRPC code 9 diff --git a/dtmcli/dtmimp/trans_base.go b/dtmcli/dtmimp/trans_base.go index 7ddd578..56df136 100644 --- a/dtmcli/dtmimp/trans_base.go +++ b/dtmcli/dtmimp/trans_base.go @@ -43,20 +43,20 @@ func (g *BranchIDGen) CurrentSubBranchID() string { // TransOptions transaction options type TransOptions struct { WaitResult bool `json:"wait_result,omitempty" gorm:"-"` - TimeoutToFail int64 `json:"timeout_to_fail,omitempty" gorm:"-"` // for trans type: xa, tcc, unit: second - RequestTimeout int64 `json:"requestTimeout" gorm:"-"` // for global trans resets request timeout, unit: second - RetryInterval int64 `json:"retry_interval,omitempty" gorm:"-"` // for trans type: msg saga xa tcc, unit: second - PassthroughHeaders []string `json:"passthrough_headers,omitempty" gorm:"-"` - BranchHeaders map[string]string `json:"branch_headers,omitempty" gorm:"-"` // custom branch headers, dtm server => service api - Concurrent bool `json:"concurrent" gorm:"-"` // for trans type: saga msg + TimeoutToFail int64 `json:"timeout_to_fail,omitempty" gorm:"-"` // for trans type: xa, tcc, unit: second + RequestTimeout int64 `json:"requestTimeout" gorm:"-"` // for global trans resets request timeout, unit: second + RetryInterval int64 `json:"retry_interval,omitempty" gorm:"-"` // for trans type: msg saga xa tcc, unit: second + PassthroughHeaders []string `json:"passthrough_headers,omitempty" gorm:"-"` // for inherit the specified gin context headers + BranchHeaders map[string]string `json:"branch_headers,omitempty" gorm:"-"` // custom branch headers, dtm server => service api + Concurrent bool `json:"concurrent" gorm:"-"` // for trans type: saga msg } // TransBase base for all trans type TransBase struct { - Gid string `json:"gid"` + Gid string `json:"gid"` // NOTE: unique in storage, can customize the generation rules instead of using server-side generation, it will help with the tracking TransType string `json:"trans_type"` Dtm string `json:"-"` - CustomData string `json:"custom_data,omitempty"` + CustomData string `json:"custom_data,omitempty"` // nosql data persistence TransOptions Steps []map[string]string `json:"steps,omitempty"` // use in MSG/SAGA diff --git a/dtmsvr/api_http.go b/dtmsvr/api_http.go index 2d8dea0..3d2e67a 100644 --- a/dtmsvr/api_http.go +++ b/dtmsvr/api_http.go @@ -37,6 +37,7 @@ func addRoute(engine *gin.Engine) { }) } +// NOTE: unique in storage, can customize the generation rules instead of using server-side generation, it will help with the tracking func newGid(c *gin.Context) interface{} { return map[string]interface{}{"gid": GenGid(), "dtm_result": dtmcli.ResultSuccess} }