fsm

command
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: MIT Imports: 3 Imported by: ? modules, 0 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

FSM behaviour demo - turnstile

A domain-neutral demonstration of the FSM thrall behaviour (StartFSM / startFSM / start_fsm), aether's second behaviour alongside the GenServer thrall. A classic turnstile:

  • locked - a coin unlocks it
  • unlocked - a push locks it again (counting pushes), or a 5s idle state timeout (autolock) locks it on its own

Events are ordinary casts/calls - the wire is unchanged, so any GenServer caller reaches it.

The same machine is written in all three languages - main.go, turnstile.ts, turnstile.py

  • with identical behaviour on the wire. Pick one manifest below; the interaction afterwards is the same regardless of language.

Run

Build the runtime once, then run one of the three variants.

export GOTOOLCHAIN=local
mise exec go@latest -- go build -o bin/aether ./cmd/aether

Go (aether.toml):

mise exec go@latest -- go build -o bin/turnstile ./examples/fsm
cd examples/fsm
AETHER_LOG_FORMAT=json AETHER_LOG_LEVEL=debug ../../bin/aether up -f aether.toml

TypeScript (aether-ts.toml):

bun install
cd examples/fsm
AETHER_LOG_FORMAT=json AETHER_LOG_LEVEL=debug ../../bin/aether up -f aether-ts.toml

Python (aether-py.toml):

cd examples/fsm
python -m venv .venv
.venv/bin/pip install -r requirements.txt
AETHER_LOG_FORMAT=json AETHER_LOG_LEVEL=debug ../../bin/aether up -f aether-py.toml

In another shell (identical for every variant):

cd examples/fsm
../../bin/aether call turnstile _state          # {"state":"locked"}
../../bin/aether cast turnstile coin            # -> unlocked (see the transition log)
../../bin/aether call turnstile _state          # {"state":"unlocked"}
../../bin/aether call turnstile push            # -> locked, replies the push count
# unlock again and wait 5s without pushing:
../../bin/aether cast turnstile coin
sleep 6
../../bin/aether call turnstile _state          # {"state":"locked"}  (auto-locked by the state timeout)

What to look for

The aether up log shows each transition and the reserved _state op answering the current state without any handler code:

{"level":"INFO","msg":"fsm transition","name":"turnstile","from":"locked","to":"unlocked"}
{"level":"INFO","msg":"fsm transition","name":"turnstile","from":"unlocked","to":"locked"}

An unknown event in a state is rejected (no_transition) rather than crashing:

../../bin/aether call turnstile push            # while locked -> error: no_transition

Documentation

Overview

Command turnstile is a domain-neutral demo of the FSM thrall behaviour (StartFSM). It is a classic two-state turnstile: `locked` accepts a coin to become `unlocked`, `unlocked` accepts a push to lock again (counting pushes), and auto-locks after 5s idle via a state timeout.

Deliberately generic - not an alarm automaton. Events are ordinary casts/calls:

aether cast turnstile coin        # -> unlocked
aether call turnstile push        # -> locked, replies with the push count
aether call turnstile _state      # -> {"state":"locked"} (reserved introspection op)

Jump to

Keyboard shortcuts

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