From 66628affd42949638a81340b83a09f5fe0a93fa5 Mon Sep 17 00:00:00 2001 From: yedf2 <120050102@qq.com> Date: Sat, 30 Oct 2021 11:29:12 +0800 Subject: [PATCH] rename AddStepOrder to AddBranchOrder --- dtmcli/saga.go | 8 ++++---- examples/http_saga.go | 4 ++-- test/saga_concurrent_test.go | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dtmcli/saga.go b/dtmcli/saga.go index fa9de44..80a3faa 100644 --- a/dtmcli/saga.go +++ b/dtmcli/saga.go @@ -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 } diff --git a/examples/http_saga.go b/examples/http_saga.go index 2558586..3e7598d 100644 --- a/examples/http_saga.go +++ b/examples/http_saga.go @@ -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) diff --git a/test/saga_concurrent_test.go b/test/saga_concurrent_test.go index 16b07c0..6983442 100644 --- a/test/saga_concurrent_test.go +++ b/test/saga_concurrent_test.go @@ -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)