Documentation ¶
Index ¶
- Constants
- Variables
- type Action
- type DefaultProcessor
- type Event
- type EventProcessor
- type EventsDef
- type State
- type StateMachine
- func (sm *StateMachine) End(end []State) *StateMachine
- func (sm *StateMachine) Events(events EventsDef) *StateMachine
- func (sm *StateMachine) Name(s string) *StateMachine
- func (sm *StateMachine) Processor(processor EventProcessor) *StateMachine
- func (sm *StateMachine) Show() string
- func (sm *StateMachine) Start(start []State) *StateMachine
- func (sm *StateMachine) States(states StatesDef) *StateMachine
- func (sm *StateMachine) Transitions(transitions ...Transition) *StateMachine
- func (sm *StateMachine) Trigger(ctx context.Context, from State, event Event) (State, error)
- type StatesDef
- type Transition
Constants ¶
View Source
const End = "[*]"
View Source
const None = ""
View Source
const Start = "[*]"
* 默认值定义
Variables ¶
View Source
var NoopProcessor = &DefaultProcessor{}
Functions ¶
This section is empty.
Types ¶
type DefaultProcessor ¶
type DefaultProcessor struct{}
* 默认实现
func (*DefaultProcessor) OnActionFailure ¶
type EventProcessor ¶
type StateMachine ¶
type StateMachine struct {
// contains filtered or unexported fields
}
* 状态机
func (*StateMachine) End ¶
func (sm *StateMachine) End(end []State) *StateMachine
func (*StateMachine) Events ¶
func (sm *StateMachine) Events(events EventsDef) *StateMachine
* 设置所有时间
func (*StateMachine) Name ¶
func (sm *StateMachine) Name(s string) *StateMachine
func (*StateMachine) Processor ¶
func (sm *StateMachine) Processor(processor EventProcessor) *StateMachine
func (*StateMachine) Start ¶
func (sm *StateMachine) Start(start []State) *StateMachine
func (*StateMachine) States ¶
func (sm *StateMachine) States(states StatesDef) *StateMachine
* 设置所有状态
func (*StateMachine) Transitions ¶
func (sm *StateMachine) Transitions(transitions ...Transition) *StateMachine
* 添加状态转换 TODO 不确定状态机,多个 Action 如何处理 ???
type Transition ¶
type Transition struct { From State Event Event To []State Action Action Processor EventProcessor }
func (Transition) String ¶
func (transfer Transition) String() string
Click to show internal directories.
Click to hide internal directories.