Browse Source

docs: TransOptions comment

pull/251/head
Rennbon 4 years ago
parent
commit
a1ce790679
  1. 4
      dtmcli/dtmimp/consts.go
  2. 16
      dtmcli/dtmimp/trans_base.go
  3. 1
      dtmsvr/api_http.go

4
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

16
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

1
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}
}

Loading…
Cancel
Save