ExGAM.Canonical.Record (ExGAM v0.1.0)

Copy Markdown View Source

Strict restoration boundary for durable ExGAM records.

Ledger values are canonical, string-keyed maps. A transition restores such a value through the record module's from_canonical/1 callback exactly once; governed code then works with the returned struct. This module intentionally provides no atom-or-string field lookup and no fallback constructor.

Record modules are passed explicitly because the set of governed event types is closed by ExGAM.Domain.Event; discovering an arbitrary decoder must never extend kernel authority.

Summary

Functions

Restores a record using its strict canonical decoder.

Requires an event identity to equal its restored record reference.

Returns the already-restored record reference.

Types

restored()

@type restored() :: %{:ref => String.t(), optional(atom()) => term()}

Functions

decode(module, canonical)

@spec decode(module(), term()) :: {:ok, struct()} | {:error, term()}

Restores a record using its strict canonical decoder.

match_identity(identity, identity)

@spec match_identity(String.t(), restored() | String.t()) ::
  :ok | {:error, :domain_event_identity_mismatch}

Requires an event identity to equal its restored record reference.

ref(map)

@spec ref(restored()) :: String.t()

Returns the already-restored record reference.