fsm

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2019 License: MIT Imports: 0 Imported by: 0

README

fsm

finite state machine in Go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StateMachine

func StateMachine(start StateFunc) error

StateMachine enters the start state and then synchronously waits for receiving a new state, which it then also enters, or nil if the machine needs to complete its work. If the state is dependent on external events, it is better to deliver them through the channel; in this case, it is recommended to run StateMachine in a separate goroutine. StateMachine should only be called once, because next transitions are determined by states.

Types

type StateFunc

type StateFunc func() (StateFunc, error)

StateFunc - state determined by the transition function to the new state. The state should determine whether it goes into some other state, including relying on incoming events through the channel (then the machine should be started as a goroutine). The target state must be initialized before returning.

Jump to

Keyboard shortcuts

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