Versions in this module Expand all Collapse all v1 v1.0.1 Dec 19, 2024 Changes in this version + var NoConditionPassedToRunTransaction = errors.New("no condition found to run transition") + var NoMatchForTransitionType = errors.New("no match for transition type") + func NewStateMachine() *stateMachine + type Condition func(stateSwitch StateSwitch, args TransitionArgs) (bool, error) + func And(operands ...Condition) Condition + func Not(operand Condition) Condition + func Or(operands ...Condition) Condition + type PostTransition func(stateSwitch StateSwitch, args TransitionArgs) error + type State string + type StateDoc struct + Description string + Name string + type StateDocJSON struct + Description string + Name string + type StateJSON struct + Description string + Name string + type StateMachine interface + AddTransition func(rule TransitionRule) + AddTransitionRule func(rule TransitionRule) + Run func(transitionType TransitionType, stateSwitch StateSwitch, args TransitionArgs) error + type StateMachineDocumentation interface + AsJSON func() ([]byte, error) + DescribeState func(state State, stateDocumentation StateDoc) + DescribeTransitionType func(transitionType TransitionType, transitionTypeDocumentation TransitionTypeDoc) + type StateMachineJSON struct + States map[string]StateJSON + TransitionRules []TransitionRuleJSON + TransitionTypes map[string]TransitionTypeJSON + type StateSwitch interface + SetState func(state State) error + State func() State + type States []State + func (s States) Contain(state State) bool + type Transition func(stateSwitch StateSwitch, args TransitionArgs) error + type TransitionArgs interface + type TransitionRule struct + Condition Condition + DestinationState State + Documentation TransitionRuleDoc + PostTransition PostTransition + SourceStates States + Transition Transition + TransitionType TransitionType + func (tr TransitionRule) IsAllowedToRun(stateSwitch StateSwitch, args TransitionArgs) (bool, error) + type TransitionRuleDoc struct + Description string + Name string + type TransitionRuleJSON struct + Description string + DestinationState string + Name string + SourceStates []string + TransitionType TransitionType + type TransitionRules []TransitionRule + func (tr TransitionRules) Find(transitionType TransitionType) TransitionRules + type TransitionType string + type TransitionTypeDoc struct + Description string + Name string + type TransitionTypeJSON struct + Description string + Name string v1.0.0 Jul 27, 2020