fsm

package
v0.0.0-...-8c2d49f Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2023 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FSM

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

FSM represents a finite state machine with a current state and list of valid state transitions.

func New

func New(initial string, states States) *FSM

New creates a new state machine, with the initial state and state transitions provided.

func (*FSM) Current

func (f *FSM) Current() string

Current returns the current state of the machine

func (*FSM) Is

func (f *FSM) Is(state string) bool

Is returns if the machine is in the state provided.

func (*FSM) State

func (f *FSM) State(state string)

State sets the current state to that provided, assuming that the state transition is valid.

type State

type State struct {
	Name string
	From []string
}

State represents a signel state and the states that are allowed to transition to this state.

type States

type States []State

States a list of states with the valid transitions

Jump to

Keyboard shortcuts

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