fsm

package
v1.2.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 10, 2019 License: Unlicense Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	Action  string
	Handler func(ctx context.Context, args ...interface{}) error
}

Action ....

type StateMachine

type StateMachine struct {
	// contains filtered or unexported fields
}

StateMachine ....

func New

func New() *StateMachine

New ....

func (*StateMachine) Event

func (m *StateMachine) Event(ctx context.Context, currentState, event string, args ...interface{}) error

Event ....

func (*StateMachine) ExportJPG

func (m *StateMachine) ExportJPG(outfile string) error

ExportJPG ....

func (*StateMachine) ExportPNG

func (m *StateMachine) ExportPNG(outfile string) error

ExportPNG 导出状态图

func (*StateMachine) ExportWithDetails

func (m *StateMachine) ExportWithDetails(outfile string, format string, layout string, scale string, more string) error

ExportWithDetails 导出状态图

func (*StateMachine) WithTransition

func (m *StateMachine) WithTransition(transition Transition) *StateMachine

WithTransition ....

func (*StateMachine) WithTransitionListener

func (m *StateMachine) WithTransitionListener(l TransitionListener) *StateMachine

WithTransitionListener ....

func (*StateMachine) WithTransitions

func (m *StateMachine) WithTransitions(transitions []Transition) *StateMachine

WithTransitions ....

type StatemError

type StatemError struct {
	BadEvent     string
	CurrentState string
}

StatemError ....

func (*StatemError) Error

func (e *StatemError) Error() string

type Transition

type Transition struct {
	From   string
	Event  string
	Action Action
	To     string
}

Transition ....

type TransitionListener

type TransitionListener interface {
	OnStateEnter(ctx context.Context, event, toState string, args ...interface{}) error
	OnAction(ctx context.Context, fromState, event string, action Action, toState string, args ...interface{}) error
	OnStateExit(ctx context.Context, fromState, event string, args ...interface{}) error
}

TransitionListener ....

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL