Skip to content

Commit 5b2441d

Browse files
authored
Revert "fix decision state machine (#531)" (#533)
This reverts commit dd3ec32.
1 parent dd3ec32 commit 5b2441d

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed

internal/internal_decision_state_machine.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ func (d *activityDecisionStateMachine) getDecision() *s.Decision {
398398
decision := createNewDecision(s.DecisionTypeScheduleActivityTask)
399399
decision.ScheduleActivityTaskDecisionAttributes = d.attributes
400400
return decision
401-
case decisionStateCanceledAfterInitiated, decisionStateCanceledBeforeInitiated:
401+
case decisionStateCanceledAfterInitiated:
402402
decision := createNewDecision(s.DecisionTypeRequestCancelActivityTask)
403403
decision.RequestCancelActivityTaskDecisionAttributes = &s.RequestCancelActivityTaskDecisionAttributes{
404404
ActivityId: d.attributes.ActivityId,
@@ -411,7 +411,7 @@ func (d *activityDecisionStateMachine) getDecision() *s.Decision {
411411

412412
func (d *activityDecisionStateMachine) handleDecisionSent() {
413413
switch d.state {
414-
case decisionStateCanceledAfterInitiated, decisionStateCanceledBeforeInitiated:
414+
case decisionStateCanceledAfterInitiated:
415415
d.moveState(decisionStateCancellationDecisionSent, eventDecisionSent)
416416
default:
417417
d.decisionStateMachineBase.handleDecisionSent()
@@ -438,7 +438,7 @@ func (d *timerDecisionStateMachine) isDone() bool {
438438

439439
func (d *timerDecisionStateMachine) handleDecisionSent() {
440440
switch d.state {
441-
case decisionStateCanceledAfterInitiated, decisionStateCanceledBeforeInitiated:
441+
case decisionStateCanceledAfterInitiated:
442442
d.moveState(decisionStateCancellationDecisionSent, eventDecisionSent)
443443
default:
444444
d.decisionStateMachineBase.handleDecisionSent()
@@ -460,7 +460,7 @@ func (d *timerDecisionStateMachine) getDecision() *s.Decision {
460460
decision := createNewDecision(s.DecisionTypeStartTimer)
461461
decision.StartTimerDecisionAttributes = d.attributes
462462
return decision
463-
case decisionStateCanceledAfterInitiated, decisionStateCanceledBeforeInitiated:
463+
case decisionStateCanceledAfterInitiated:
464464
decision := createNewDecision(s.DecisionTypeCancelTimer)
465465
decision.CancelTimerDecisionAttributes = &s.CancelTimerDecisionAttributes{
466466
TimerId: d.attributes.TimerId,

internal/internal_decision_state_machine_test.go

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,25 +75,19 @@ func Test_TimerStateMachine_CompletedAfterCancel(t *testing.T) {
7575
h := newDecisionsHelper()
7676
d := h.startTimer(attributes)
7777
require.Equal(t, decisionStateCreated, d.getState())
78-
7978
decisions := h.getDecisions(true)
8079
require.Equal(t, decisionStateDecisionSent, d.getState())
8180
require.Equal(t, 1, len(decisions))
8281
require.Equal(t, s.DecisionTypeStartTimer, decisions[0].GetDecisionType())
83-
8482
h.cancelTimer(timerID)
8583
require.Equal(t, decisionStateCanceledBeforeInitiated, d.getState())
86-
decisions = h.getDecisions(false)
87-
require.Equal(t, 1, len(decisions))
88-
require.Equal(t, s.DecisionTypeCancelTimer, decisions[0].GetDecisionType())
89-
84+
require.Equal(t, 0, len(h.getDecisions(true)))
9085
h.handleTimerStarted(timerID)
9186
require.Equal(t, decisionStateCanceledAfterInitiated, d.getState())
9287
decisions = h.getDecisions(true)
9388
require.Equal(t, 1, len(decisions))
9489
require.Equal(t, s.DecisionTypeCancelTimer, decisions[0].GetDecisionType())
9590
require.Equal(t, decisionStateCancellationDecisionSent, d.getState())
96-
9791
h.handleTimerClosed(timerID)
9892
require.Equal(t, decisionStateCompletedAfterCancellationDecisionSent, d.getState())
9993
}
@@ -222,9 +216,7 @@ func Test_ActivityStateMachine_CancelAfterSent(t *testing.T) {
222216
// cancel activity
223217
h.requestCancelActivityTask(activityID)
224218
require.Equal(t, decisionStateCanceledBeforeInitiated, d.getState())
225-
decisions = h.getDecisions(false)
226-
require.Equal(t, 1, len(decisions))
227-
require.Equal(t, s.DecisionTypeRequestCancelActivityTask, decisions[0].GetDecisionType())
219+
require.Equal(t, 0, len(h.getDecisions(true)))
228220

229221
// activity scheduled
230222
h.handleActivityTaskScheduled(1, activityID)
@@ -256,9 +248,7 @@ func Test_ActivityStateMachine_CompletedAfterCancel(t *testing.T) {
256248
// cancel activity
257249
h.requestCancelActivityTask(activityID)
258250
require.Equal(t, decisionStateCanceledBeforeInitiated, d.getState())
259-
decisions = h.getDecisions(false)
260-
require.Equal(t, 1, len(decisions))
261-
require.Equal(t, s.DecisionTypeRequestCancelActivityTask, decisions[0].GetDecisionType())
251+
require.Equal(t, 0, len(h.getDecisions(true)))
262252

263253
// activity scheduled
264254
h.handleActivityTaskScheduled(1, activityID)

0 commit comments

Comments
 (0)