Finitomata
The FSM boilerplate based on callbacks
provides a boilerplate for finite-state-machine implementation, letting you concentrate on business logic instead of process management and transition bookkeeping. It reads the FSM description from a string in PlantUML (
:state_diagram
) or Mermaid (
:flowchart
) syntax, validates that it is consistent (a single initial state, one or more final states, no orphan states), and generates a
GenServer
you can use standalone or inside a supervision tree.
The generated FSM requires only one mandatory callback,
on_transition/4
;
on_failure/3
,
on_enter/2
,
on_exit/2
,
on_terminate/1
and
on_timer/2
are all optional with sensible defaults. Options tune its behaviour further:
timer:
for recurring callbacks,
auto_terminate:
to transition to the end state automatically,
ensure_entry:
to retry a transition until it succeeds,
hibernate:
,
cache_state:
and pluggable persistence (built-in ETS and DETS adapters).
Infinitomata
, shipped in the same package, is a self-contained distributed implementation built on
:pg
for running the same FSMs across a cluster.
Finitomata.ExUnit
provides a dependency-free test harness with
assert_transition/3
, failure assertions and property-based event generation.