AshReplicant (AshReplicant v0.2.0)

Copy Markdown View Source

An Ash-native Replicant.Sink adapter. Mirrors a source Postgres database's committed CDC changes into AshPostgres resources with effect-once semantics (dup = 0, loss = 0), resolving resource, tenant, and classification in the Ash layer while keeping replicant tenant-blind.

This is the ash_postgres-of-replicant: replicant is the tenant-blind CDC transport; multitenancy and classification live here, one layer up.

Summary

Functions

Start a CDC pipeline that mirrors into Ash resources. opts

Stop a running pipeline by slot name (idempotent). Clears the cached resolver index from :persistent_term so a subsequent start_link/1 rebuilds it fresh.

The library version string.

Functions

start_link(opts)

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

Start a CDC pipeline that mirrors into Ash resources. opts:

  • :sink — a module built with use AshReplicant.Sink (carries repo/domains/checkpoint/slot).
  • :connection — Postgrex opts (point at a standby).
  • :publication — replication identifier.
  • :go_forward_only, :snapshot — passed through to Replicant.start_link/1.

The slot_name is NOT a start_link option — it is baked into the sink via use AshReplicant.Sink, slot_name: ... and is the single source of truth for both the :persistent_term index key and the replication slot.

Builds the {schema,table}=>resource index from the sink's domains, fails closed on a duplicate or missing source table, caches the index in :persistent_term, then starts the replicant pipeline.

stop_supervised(slot_name)

@spec stop_supervised(String.t()) :: :ok

Stop a running pipeline by slot name (idempotent). Clears the cached resolver index from :persistent_term so a subsequent start_link/1 rebuilds it fresh.

version()

@spec version() :: String.t()

The library version string.