Spectre.GAM.Ledger.Store.Support (Spectre v0.4.0)

Copy Markdown View Source

Storage-neutral helpers for ledger adapters.

This module owns portable result shapes and storage-neutral batch checks. Locking, transactions, durability barriers, encoding and recovery remain in each adapter, where their guarantees can be audited without indirection.

Summary

Functions

Classifies a prospective append against a serialized adapter's cached Domain.

Builds metadata for an already verified non-empty logical batch.

Builds batch metadata from already decoded storage columns.

Returns the initial in-memory state shared by serialized adapters.

Installs an already verified batch in a serialized adapter's cached Domain.

Builds the portable snapshot returned by a serialized adapter.

Functions

append_status(domain, batch_id, identity, expected_revision, fault)

@spec append_status(
  map(),
  String.t(),
  Spectre.GAM.Ledger.Entry.digest(),
  non_neg_integer(),
  atom() | nil
) :: :new | {:existing, non_neg_integer()} | {:error, term()}

Classifies a prospective append against a serialized adapter's cached Domain.

batch_info(batch_id, identity, expected_revision, last)

Builds metadata for an already verified non-empty logical batch.

batch_info(batch_id, identity, expected, first, last, count, head)

Builds batch metadata from already decoded storage columns.

empty_domain()

@spec empty_domain() :: map()

Returns the initial in-memory state shared by serialized adapters.

install_batch(domain, batch_id, identity, expected_revision, entries)

Installs an already verified batch in a serialized adapter's cached Domain.

snapshot(domain_ref, domain)

@spec snapshot(String.t(), map()) :: Spectre.GAM.Ledger.snapshot()

Builds the portable snapshot returned by a serialized adapter.