Documentation ¶
Overview ¶
Package fsmtool contains tools for creating FSMs, particularly transitioning between states. State machines in Go is quite simple so there's no need for a library that handles *everything*.
Index ¶
- type StateTransitionTable
- func (s *StateTransitionTable) AddTransitions(states ...interface{}) bool
- func (s *StateTransitionTable) Apply(newState interface{}, code func(stt *StateTransitionTable)) bool
- func (s *StateTransitionTable) DumpTransitions(writer io.Writer)
- func (s *StateTransitionTable) SetState(state interface{}) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type StateTransitionTable ¶
type StateTransitionTable struct { CurrentState interface{} LogOnError bool PanicOnError bool LogStates bool LogTransitions bool Name string AllowInvalid bool // Allow invalid state transitions (but log errors) ValidTransitions map[interface{}][]interface{} }
StateTransitionTable is a tool to manage state transitions.
func NewStateTransitionTable ¶
func NewStateTransitionTable(initialState interface{}) *StateTransitionTable
NewStateTransitionTable creates a new state transition table.
func (*StateTransitionTable) AddTransitions ¶
func (s *StateTransitionTable) AddTransitions(states ...interface{}) bool
AddTransitions adds a state transition to the table
func (*StateTransitionTable) Apply ¶
func (s *StateTransitionTable) Apply(newState interface{}, code func(stt *StateTransitionTable)) bool
Apply applies the state transition with the given function and logs debug information
func (*StateTransitionTable) DumpTransitions ¶
func (s *StateTransitionTable) DumpTransitions(writer io.Writer)
DumpTransitions dumps the transitions in a dot-compatible format
func (*StateTransitionTable) SetState ¶
func (s *StateTransitionTable) SetState(state interface{}) bool
SetState sets a new state if it is valid
Click to show internal directories.
Click to hide internal directories.