AshReplicant.Apply (AshReplicant v0.2.0)

Copy Markdown View Source

Applies one %Replicant.Change{} to the mirror. An insert/update goes through a single-row Ash action; a delete issues one atomic bulk_destroy over a PK-filtered query; a :mirror truncate deletes the mirror table directly.

Called once per change, in delivery (ordinal) order, inside the sink's transaction. Raises on any failure so the surrounding Repo.transaction rolls the whole transaction back — the effect-once fail-closed contract. Never re-orders or coalesces changes: a spilled transaction's changes is a lazy single-pass Enumerable, so the caller iterates it exactly once.

Summary

Functions

Apply a change under config (%{resolver_index:, repo:, authorize?:}). Returns :ok; raises AshReplicant.Error (value-free) on failure. A change whose {schema, table} is not a mirror target is ignored.

Functions

apply_change(config, change)

@spec apply_change(map(), Replicant.Change.t()) :: :ok

Apply a change under config (%{resolver_index:, repo:, authorize?:}). Returns :ok; raises AshReplicant.Error (value-free) on failure. A change whose {schema, table} is not a mirror target is ignored.