fsm

package module
v0.0.0-...-b90c612 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2017 License: MIT Imports: 0 Imported by: 3 modules, 3 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Go Carrot

FSM

This package contains a simple interface for a finite-state machine in Go.

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildState

type BuildState func(Emitter, Traverser) *State

BuildState is a function that generates a State with access to a specific Emitter and Traverser

type Emitter

type Emitter interface {
	Emit(interface{}) error
}

Emitter is a generic interface to output arbitrary data. Emit is generally called from State.EntryAction.

type State

type State struct {
	Slug        string
	EntryAction func() error
	Transition  func(interface{}) *State
}

State represents an individual state in a larger state machine

type StateMachine

type StateMachine map[string]BuildState

StateMachine is a k:v map that maps the slug of States to BuildState functions

type Store

type Store interface {
	FetchTraverser(uuid string) (Traverser, error)
	CreateTraverser(uuid string) (Traverser, error)
}

A Store is a generic interface responsible for managing The fetching and creation of traversers

type Traverser

type Traverser interface {
	UUID() string
	SetUUID(string)
	CurrentState() string
	SetCurrentState(string)
	Upsert(key string, value interface{}) error
	Fetch(key string) (interface{}, error)
	Delete(key string) error
}

A Traverser is an individual that is traversing the StateMachine. This interface that is responsible for managing the state of that individual

Jump to

Keyboard shortcuts

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