Skip to content

Commit

Permalink
internal/statemachine: rename state succeeded -> success to conform w…
Browse files Browse the repository at this point in the history
…ith condition states

Task states are mapped to Condition states
  • Loading branch information
joelrebel committed May 4, 2023
1 parent bcbdc6b commit d28582a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions internal/statemachine/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import (
const (

// state for successful actions
StateActionSuccessful sw.State = "success"
StateActionSuccessful sw.State = model.StateSucceeded
// state for failed actions
StateActionFailed sw.State = "failed"
StateActionFailed sw.State = model.StateFailed

// transition for completed actions
TransitionTypeActionSuccess sw.TransitionType = "success"
TransitionTypeActionSuccess sw.TransitionType = "succeeded"
// transition for failed actions
TransitionTypeActionFailed sw.TransitionType = "failed"
)
Expand Down
22 changes: 11 additions & 11 deletions internal/statemachine/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ import (
)

const (
// TransitionTypeQuery is the the transition
TransitionTypeQuery sw.TransitionType = "query"
TransitionTypePlan sw.TransitionType = "plan"
TransitionTypeRun sw.TransitionType = "run"
TransitionTypeActive sw.TransitionType = "active"
TransitionTypeQuery sw.TransitionType = "query"
TransitionTypePlan sw.TransitionType = "plan"
TransitionTypeRun sw.TransitionType = "run"

// TransitionTypeTaskSuccess is transition type for successful tasks
TransitionTypeTaskSuccess sw.TransitionType = "success"
TransitionTypeTaskSuccess sw.TransitionType = "succeeded"
// TransitionTypeTaskFailed is transition type for failed tasks
TransitionTypeTaskFail sw.TransitionType = "failed"
)
Expand Down Expand Up @@ -197,7 +197,7 @@ func NewTaskStateMachine(ctx context.Context, task *model.Task, handler TaskTran
m.sm.AddTransition(sw.TransitionRule{
TransitionType: TransitionTypeRun,
SourceStates: sw.States{model.StateActive},
DestinationState: model.StateSuccess,
DestinationState: model.StateSucceeded,
Condition: handler.ValidatePlan,
Transition: handler.Run,
PostTransition: handler.PersistState,
Expand All @@ -209,7 +209,7 @@ func NewTaskStateMachine(ctx context.Context, task *model.Task, handler TaskTran

m.sm.AddTransition(sw.TransitionRule{
TransitionType: TransitionTypeTaskFail,
SourceStates: sw.States{model.StateQueued, model.StateActive},
SourceStates: sw.States{model.StatePending, model.StateActive},
DestinationState: model.StateFailed,
Condition: nil,
Transition: handler.TaskFailed,
Expand All @@ -223,7 +223,7 @@ func NewTaskStateMachine(ctx context.Context, task *model.Task, handler TaskTran
m.sm.AddTransition(sw.TransitionRule{
TransitionType: TransitionTypeTaskSuccess,
SourceStates: sw.States{model.StateActive},
DestinationState: model.StateSuccess,
DestinationState: model.StateSucceeded,
Condition: nil,
Transition: handler.TaskSuccessful,
PostTransition: handler.PersistState,
Expand All @@ -237,12 +237,12 @@ func NewTaskStateMachine(ctx context.Context, task *model.Task, handler TaskTran
}

func (m *TaskStateMachine) addDocumentation() {
m.sm.DescribeState(model.StateRequested, sw.StateDoc{
m.sm.DescribeState(model.StatePending, sw.StateDoc{
Name: "Requested",
Description: "In this state the task has been requested (this is done outside of the state machine).",
})

m.sm.DescribeState(model.StateQueued, sw.StateDoc{
m.sm.DescribeState(model.StatePending, sw.StateDoc{
Name: "Queued",
Description: "In this state the task is being initialized (this is done outside of the state machine).",
})
Expand All @@ -257,7 +257,7 @@ func (m *TaskStateMachine) addDocumentation() {
Description: "In this state the task execution has failed.",
})

m.sm.DescribeState(model.StateSuccess, sw.StateDoc{
m.sm.DescribeState(model.StateSucceeded, sw.StateDoc{
Name: "Success",
Description: "In this state the task execution has completed successfully.",
})
Expand Down

0 comments on commit d28582a

Please sign in to comment.