Concord.Sync.ChangeLog (Concord v2.0.0)

Copy Markdown View Source

ETS-backed bounded change log for Concord.

Stores %Event{} records keyed by {revision, op_index} in an :ordered_set ETS table. Supports range queries for historical replay and automatic compaction to bound memory usage.

Summary

Functions

Appends events to the change log. Called from the state machine on every mutation.

Returns events in the revision range [from, to] (inclusive).

Compacts the change log to keep only entries after keep_revision.

Returns the earliest revision still in the change log, or 0 if empty.

Ensures the change log ETS table exists.

Functions

append(events)

@spec append([Concord.Sync.Event.t()]) :: :ok

Appends events to the change log. Called from the state machine on every mutation.

changes(from_revision, to_revision, opts \\ [])

Returns events in the revision range [from, to] (inclusive).

compact(keep_revision)

@spec compact(non_neg_integer()) :: non_neg_integer()

Compacts the change log to keep only entries after keep_revision.

earliest_revision()

@spec earliest_revision() :: non_neg_integer()

Returns the earliest revision still in the change log, or 0 if empty.

ensure_table()

Ensures the change log ETS table exists.