-
Notifications
You must be signed in to change notification settings - Fork 0
/
state_action.go
19 lines (16 loc) · 979 Bytes
/
state_action.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package gfsm
// EventContext is an abstraction that represent any data that user passes to the current state for execution
// in StateMachineHandler.ProcessEvent(...) call. The data will be forwarded as StateAction.Execute(...) argument.
type EventContext interface{}
// StateMachineContext is an abstraction that represent any data that user passes to the state machine. The data will
// be forwarded as StateAction.OnEnter amd OnExit arguments.
type StateMachineContext interface{}
// StateAction is the interface which each state must implement.
type StateAction[StateIdentifier comparable] interface {
// OnEnter will be called once on the state entering.
OnEnter(smCtx StateMachineContext)
// OnExit will be called once on the state exiting.
OnExit(smCtx StateMachineContext)
// Execute is the call that state machine routes to the current state from StateMachineHandler.ProcessEvent(...)
Execute(smCtx StateMachineContext, eventCtx EventContext) StateIdentifier
}