Durable OTP :mnesia implementation of Rheo.Backend.
Always available (OTP :mnesia is an included application). Prefer when you
want ETS-shaped tables that survive process restart on a single node without
Mongo, Postgres, or Redis. Prefer Redis / Ecto Postgres / Mongo when several
BEAM nodes must fetch the same group (distributed: false in v0.11).
Prefer the Rheo facade for application code. The opaque handle is this
process's registered name (default Rheo.Mnesia), started via child_spec/1.
When to use
- Single-node hosts that need durability across GenServer restart
- Local / embedded deployments that already rely on OTP disk schema
- Bridging from ETS prototypes without introducing an external database
Do not use for multi-node lease arbitration in v0.11
(distributed: false). Multiple Rheo instances on one node share the Mnesia
schema but use unique table name prefixes.
Capabilities
durable: true— survives process restart when the Mnesia directory is keptdistributed: false— single-nodedisc_copiesonly (ADR 028)batch_writes: true,ordered_range_scan: truereplay: true,partitions: true,contiguous_frontier: truesecondary_indexes: false—query/2filters in-processatomic_compare_and_set: false—dirty_writeis not:mnesia.sync_transactioncrash durabilitynotifications: false
Tables
ETS-shaped disc_copies tables under a per-handle prefix:
<prefix>.streams / .events / .groups / .deliveries
<prefix>.event_ids / .delivery_by_seq / .open_deliveriesOptions
:name— handle / process name (defaultdefault_handle/0):dir— Mnesia directory (default underSystem.tmp_dir!/0)
Supervision example
children = [
{Rheo, name: MyRheo, backend: {Rheo.Backend.Mnesia, dir: "/var/lib/rheo/mnesia"}}
]Named handle:
children = [
{Rheo,
name: MyRheo,
backend: {Rheo.Backend.Mnesia, name: MyRheo.Mnesia, dir: "/var/lib/rheo/mnesia"}}
]Callback semantics are documented on Rheo.Backend.
Summary
Functions
@spec child_spec(keyword()) :: Supervisor.child_spec()
Child spec for the Mnesia GenServer (backend handle).
Arguments
opts— keyword options::name— handle / process name (defaultdefault_handle/0):dir— Mnesia directory (default underSystem.tmp_dir!/0)
Examples
iex> spec = Rheo.Backend.Mnesia.child_spec(name: :demo_mnesia, dir: "/tmp/rheo_mnesia_demo")
iex> {spec.id, elem(spec.start, 0), spec.type}
{{Rheo.Backend.Mnesia, :demo_mnesia}, Rheo.Backend.Mnesia, :worker}Returns
A supervisor child spec map. The directory is created and the schema started when the GenServer initializes.
@spec default_handle() :: atom()
Default Mnesia handle name for the Rheo instance.
Examples
iex> Rheo.Backend.Mnesia.default_handle()
Rheo.MnesiaReturns
A process name atom (Rheo.Mnesia).