sm

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 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 IMachine

type IMachine interface {
	Transition(event string) string
	Current() string
}

IMachine machine interface

type Machine

type Machine struct {
	ID      string
	Initial string

	States      StateMap
	Subscribers []func(curr, next string)
	// contains filtered or unexported fields
}

Machine datatype

func (*Machine) Current

func (m *Machine) Current() string

Current returns current state

func (*Machine) Transition

func (m *Machine) Transition(event string) string

Transition transitions to next state

type MachineState

type MachineState struct {
	On TransitionMap
}

MachineState is State of machine

type MachineTransition

type MachineTransition struct {
	Actions []func(current, next string)
	Cond    func(current, next string) bool
	To      string
}

MachineTransition transition map

type StateMap

type StateMap map[string]MachineState

StateMap maps state

type TransitionMap

type TransitionMap map[string]MachineTransition

TransitionMap map with transitions

Jump to

Keyboard shortcuts

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