statechart

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 13 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.

Documentation

Overview

Package statechart is the machine that is always in some state and moves between states when events arrive.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chart

type Chart struct {
	Initial string            `json:"initial,omitzero"`
	States  map[string]*State `json:"states"`
}

Chart is the full form of a statechart's own part of a definition.

type Send

type Send struct {
	To      string               `json:"to,omitzero"`
	Address *machine.AddressSpec `json:"address,omitzero"`
	Event   string               `json:"event"`
	Data    any                  `json:"data,omitzero"`
}

Send is the chart's one action: a named event to the parent, to a child, or to a run by its address.

type State

type State struct {
	Initial string                      `json:"initial,omitzero"`
	States  map[string]*State           `json:"states,omitzero"`
	Job     *machine.JobSpec            `json:"job,omitzero"`
	Jobs    map[string]*machine.JobSpec `json:"jobs,omitzero"`
	// Defer names events that are kept, not dropped, when no rule takes
	// them while the state is active.
	Defer  []string          `json:"defer,omitzero"`
	Ticket string            `json:"ticket,omitzero"`
	Timers map[string]string `json:"timers,omitzero"` // the time of each, by its name
	Entry  []Send            `json:"entry,omitzero"`
	Exit   []Send            `json:"exit,omitzero"`
	// On is where to go on each event, by its name: done, failed, a
	// timer, a ticket's answer, or any other event.
	On map[string][]Transition `json:"on,omitzero"`
	// End is done or failed in a final state: how it ends the state that
	// holds it, or the chart.
	End    string `json:"end,omitzero"`
	Output any    `json:"output,omitzero"`
}

State is one state in full form.

type Transition

type Transition struct {
	Go   string `json:"go,omitzero"`
	When string `json:"when,omitzero"`
	Send []Send `json:"send,omitzero"`
}

Transition is one candidate of a rule.

Jump to

Keyboard shortcuts

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