Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidTransaction = errors.New("invalid transaction") ErrNotRegisteredState = errors.New("state is not registered") )
Functions ¶
This section is empty.
Types ¶
type Callback ¶
CallbackNoReturn is used as a callback with cancellation ability. Example: WithOnLeaveState, OnLeaveAnyState
type CallbackNoReturn ¶
type CallbackNoReturn[S, T constraints.Ordered] func(ctx context.Context, e *Event[S, T])
CallbackNoReturn is used as a callback with no cancellation ability. Example: WithOnEnterState, OnEnterAnyState
type Config ¶
type Config[S, T constraints.Ordered] struct { // contains filtered or unexported fields }
func NewStateMachineConfig ¶
func NewStateMachineConfig[S, T constraints.Ordered]() *Config[S, T]
func (*Config[S, T]) AddState ¶
func (c *Config[S, T]) AddState(s S, opts ...StateOption[S, T]) *Config[S, T]
func (*Config[S, T]) OnEnterAnyState ¶
func (c *Config[S, T]) OnEnterAnyState(f CallbackNoReturn[S, T]) *Config[S, T]
func (*Config[S, T]) OnLeaveAnyState ¶
type Event ¶
type Event[S, T constraints.Ordered] struct { FSM *FSM[S, T] Transaction T Src S Dst S }
Event is the info that get passed as a reference in the Callback
type FSM ¶
type FSM[S, T constraints.Ordered] struct { // contains filtered or unexported fields }
func NewFSM ¶
func NewFSM[S, T constraints.Ordered](initState S, config *Config[S, T]) (*FSM[S, T], error)
type StateOption ¶
type StateOption[S, T constraints.Ordered] func(property *stateProperty[S, T])
func WithOnEnterState ¶
func WithOnEnterState[S, T constraints.Ordered](f CallbackNoReturn[S, T]) StateOption[S, T]
func WithOnLeaveState ¶
func WithOnLeaveState[S, T constraints.Ordered](f Callback[S, T]) StateOption[S, T]
func WithPermit ¶
func WithPermit[S, T constraints.Ordered](t T, s S) StateOption[S, T]
Click to show internal directories.
Click to hide internal directories.