Documentation ¶
Index ¶
- Variables
- type Event
- type Handler
- type StateMachine
- func (sm *StateMachine) Can(transition string) bool
- func (sm *StateMachine) Cannot(transition string) bool
- func (sm *StateMachine) Is(sate string) bool
- func (sm *StateMachine) SetState(state string)
- func (sm *StateMachine) State() string
- func (sm *StateMachine) Transition(name string) *Transition
- func (sm *StateMachine) Trigger(ctx context.Context, transition string, args ...interface{}) error
- type Transition
- func (t *Transition) After(h Handler) *Transition
- func (t *Transition) AfterTransition(h Handler) *Transition
- func (t *Transition) Before(h Handler) *Transition
- func (t *Transition) BeforeTransition(h Handler) *Transition
- func (t *Transition) EnterState(state string, h Handler) *Transition
- func (t *Transition) From(states ...string) *Transition
- func (t *Transition) LeaveState(state string, h Handler) *Transition
- func (t *Transition) StateMachine() *StateMachine
- func (t *Transition) To(state string) *Transition
- func (t *Transition) Transition(name string) *Transition
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrTransitionNotFound = errors.New("fsm: transition was not found") ErrInvalidState = errors.New("fsm: inappropriate in current state") )
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event struct { StateMachine *StateMachine Transitions string From string To string Args []interface{} }
type StateMachine ¶
type StateMachine struct {
// contains filtered or unexported fields
}
func New ¶
func New(initialState string) *StateMachine
func (*StateMachine) Can ¶
func (sm *StateMachine) Can(transition string) bool
func (*StateMachine) Cannot ¶
func (sm *StateMachine) Cannot(transition string) bool
func (*StateMachine) Is ¶
func (sm *StateMachine) Is(sate string) bool
func (*StateMachine) SetState ¶
func (sm *StateMachine) SetState(state string)
func (*StateMachine) State ¶
func (sm *StateMachine) State() string
func (*StateMachine) Transition ¶
func (sm *StateMachine) Transition(name string) *Transition
type Transition ¶
type Transition struct {
// contains filtered or unexported fields
}
func (*Transition) After ¶
func (t *Transition) After(h Handler) *Transition
func (*Transition) AfterTransition ¶
func (t *Transition) AfterTransition(h Handler) *Transition
func (*Transition) Before ¶
func (t *Transition) Before(h Handler) *Transition
func (*Transition) BeforeTransition ¶
func (t *Transition) BeforeTransition(h Handler) *Transition
func (*Transition) EnterState ¶
func (t *Transition) EnterState(state string, h Handler) *Transition
func (*Transition) From ¶
func (t *Transition) From(states ...string) *Transition
func (*Transition) LeaveState ¶
func (t *Transition) LeaveState(state string, h Handler) *Transition
func (*Transition) StateMachine ¶
func (t *Transition) StateMachine() *StateMachine
func (*Transition) To ¶
func (t *Transition) To(state string) *Transition
func (*Transition) Transition ¶
func (t *Transition) Transition(name string) *Transition
Click to show internal directories.
Click to hide internal directories.