state

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package state is the statechart engine of ADR-0008 and ADR-0040: which named transition a command means, which transitions leave a state, and the chain of eventless transitions a commit follows after its recalculation, with its bound. It evaluates no guard itself: the store, which holds the document and the VM, reports whether each guard holds.

Index

Constants

View Source
const MaxEventless = 8

MaxEventless is the bound of eventless transitions one command may fire (ADR-0008); past it the commit is refused with too_many_transitions.

Variables

This section is empty.

Functions

func Chain

func Chain(cls *model.Class, from string, path []string, fires func(t *model.Transition, from string) bool) (_ []string, ok bool)

Chain follows the eventless transitions from a state: at every step the first one in definition order that leaves the current state and whose guard holds, as fires reports it, until none does. The states entered are appended to path, which the caller gives with the states visited so far. ok is false when more than MaxEventless fired; path then ends at the bound. The loop allocates nothing beyond the growth of path.

func From

func From(t *model.Transition, state string) bool

From reports whether the transition leaves the state.

func Leaving

func Leaving(cls *model.Class, state string) []*model.Transition

Leaving lists the named transitions whose sources include the state, in definition order: what Transitions and Preview list (ADR-0040).

func Named

func Named(cls *model.Class, name string) *model.Transition

Named returns the class's named transition, matched without regard to case, or nil when there is none.

func Names

func Names(cls *model.Class) []string

Names lists the names of the class's named transitions in definition order, for messages.

Types

This section is empty.

Jump to

Keyboard shortcuts

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