ExGAM.Ledger.Store.Mnesia (ExGAM v0.1.0)

Copy Markdown View Source

Transactional Mnesia adapter for the append-only Domain ledger.

The host owns the Mnesia schema, directory and cluster membership. ensure_tables/1 is an explicit installation helper; normal ledger operations never create schemas or tables. Every append uses one synchronous Mnesia transaction and a write lock on the Domain head, so the expected revision, batch idempotency record, entries and new head move together. Tables must use durable copies and majority commits; volatile deployments should use ExGAM.Ledger.Store.ETS instead.

The adapter stores canonical ExGAM.Ledger.Entry bytes rather than native structs. Table names and replica type are explicit deployment configuration. compressed: true stores entries in a bounded, lossless compression envelope; it does not require changing the Mnesia schema or rewrite existing rows. :disc_copies still holds table data in RAM; use :disc_only_copies when that deployment tradeoff is desired. Native batch reads use revision keys.

Summary

Functions

Creates the three required tables in an already running Mnesia schema.

Functions

ensure_tables(opts \\ [])

@spec ensure_tables(keyword()) :: :ok | {:error, term()}

Creates the three required tables in an already running Mnesia schema.