Skip to content

Commit

Permalink
rename AddStepOrder to AddBranchOrder
Browse files Browse the repository at this point in the history
  • Loading branch information
yedf2 committed Oct 30, 2021
1 parent 07d4be5 commit 66628af
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions dtmcli/saga.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ func (s *Saga) Add(action string, compensate string, postData interface{}) *Saga
return s
}

// AddStepOrder specify that step should be after preSteps. Step is larger than all the element in preSteps
func (s *Saga) AddStepOrder(step int, preSteps []int) *Saga {
PanicIf(step > len(s.Steps), fmt.Errorf("step value: %d is invalid. which cannot be larger than total steps: %d", step, len(s.Steps)))
s.orders[step] = preSteps
// AddBranchOrder specify that branch should be after preBranches. branch should is larger than all the element in preBranches
func (s *Saga) AddBranchOrder(branch int, preBranches []int) *Saga {
PanicIf(branch > len(s.Steps), fmt.Errorf("step value: %d is invalid. which cannot be larger than total steps: %d", branch, len(s.Steps)))
s.orders[branch] = preBranches
return s
}

Expand Down
4 changes: 2 additions & 2 deletions examples/http_saga.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ func init() {
Add(Busi+"/TransIn", Busi+"/TransInRevert", req).
Add(Busi+"/TransIn", Busi+"/TransInRevert", req).
EnableConcurrent().
AddStepOrder(2, []int{0, 1}).
AddStepOrder(3, []int{0, 1})
AddBranchOrder(2, []int{0, 1}).
AddBranchOrder(3, []int{0, 1})
dtmcli.Logf("concurrent saga busi trans submit")
err := csaga.Submit()
dtmcli.Logf("result gid is: %s", csaga.Gid)
Expand Down
2 changes: 1 addition & 1 deletion test/saga_concurrent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func csagaRollback(t *testing.T) {

func csagaRollback2(t *testing.T) {
csaga := genCSaga("gid-rollback-csaga2", true, false)
csaga.AddStepOrder(1, []int{0})
csaga.AddBranchOrder(1, []int{0})
err := csaga.Submit()
assert.Nil(t, err)
waitTransProcessed(csaga.Gid)
Expand Down

0 comments on commit 66628af

Please sign in to comment.