gsm

package
v1.0.28 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAndRun

func NewAndRun(logger *log.Logger, stateEntries []StateEntry, firstState StateT, firstEvent EventT, userData interface{}) (err error)

创建并运行状态机 logger: 设置logger stateEntries: 状态机表 firstState: 初始state firstEvent: 初始event data: 用户数据 response: 应答回调

Types

type EventNode

type EventNode struct {
	NextState StateT
	Callback  func(*GSM, interface{})
}

type EventT

type EventT string

type GSM

type GSM struct {
	Logger *log.Logger
	// contains filtered or unexported fields
}

func (*GSM) TriggerToNextState

func (g *GSM) TriggerToNextState(event EventT, data interface{})

根据event触发下一个state

type StateEntry

type StateEntry struct {
	State     StateT
	Event     EventT
	NextState StateT
	Callback  func(*GSM, interface{})
}

type StateNode

type StateNode map[EventT]EventNode

type StateT

type StateT string

type TransData

type TransData struct {
	Event EventT
	Data  interface{}
}

Jump to

Keyboard shortcuts

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