AshArcadic.Replicant.Info (AshArcadic v0.2.0)

Copy Markdown View Source

Introspection for the replicant do ... end AshArcadic.Replicant extension.

Generates the replicant_<option>/1 ({:ok, value} | :error) and replicant_<option>!/1 accessors for every option, plus the hand-written helpers below: source_table/1 (the declared value — required, no reflection fallback), source_schema/1 (declared value, else "public"), tenant_attribute/1, skip/1, and on_truncate/1.

Summary

Functions

The upstream TRUNCATE policy: :halt (default, fail-closed) or :mirror.

Policy for an upstream TRUNCATE: :halt (fail-closed, default) or :mirror (raw-delete the mirror rows in-txn).

Policy for an upstream TRUNCATE: :halt (fail-closed, default) or :mirror (raw-delete the mirror rows in-txn).

replicant DSL options

Source non-identity columns excluded from the mirror write. Must NOT name the primary key — a dropped PK would forge a fresh vertex identity on every apply, so a skipped PK is rejected at compile by ValidatePrimaryKeyNotSkipped.

Source non-identity columns excluded from the mirror write. Must NOT name the primary key — a dropped PK would forge a fresh vertex identity on every apply, so a skipped PK is rejected at compile by ValidatePrimaryKeyNotSkipped.

Source Postgres schema name.

Source Postgres schema name.

Source Postgres table name. Required — a graph resource's own arcade label is not its Postgres source table, so no reflection fallback is offered.

Source Postgres table name. Required — a graph resource's own arcade label is not its Postgres source table, so no reflection fallback is offered.

Source column carrying the tenant. Resolved per row and passed as tenant: to the mirror action. Requires the source table to be REPLICA IDENTITY FULL: a :delete / PK-changing :update resolves the tenant from old_record, which is key-only under the default replica identity — the tenant column would be absent, so the apply fails closed :tenant_required and halts the whole transaction.

Source column carrying the tenant. Resolved per row and passed as tenant: to the mirror action. Requires the source table to be REPLICA IDENTITY FULL: a :delete / PK-changing :update resolves the tenant from old_record, which is key-only under the default replica identity — the tenant column would be absent, so the apply fails closed :tenant_required and halts the whole transaction.

Source columns excluded from the mirror write, else [] when undeclared.

The source Postgres schema for the resource: the explicit source_schema, else "public".

The source Postgres table for the resource. Required — no reflection fallback.

The source column carrying the tenant, else nil when undeclared.

Functions

on_truncate(resource)

@spec on_truncate(Ash.Resource.t()) :: :halt | :mirror

The upstream TRUNCATE policy: :halt (default, fail-closed) or :mirror.

replicant_on_truncate(dsl_or_extended)

@spec replicant_on_truncate(dsl_or_extended :: module() | map()) ::
  {:ok, :mirror | :halt} | :error

Policy for an upstream TRUNCATE: :halt (fail-closed, default) or :mirror (raw-delete the mirror rows in-txn).

replicant_on_truncate!(dsl_or_extended)

@spec replicant_on_truncate!(dsl_or_extended :: module() | map()) ::
  (:mirror | :halt) | no_return()

Policy for an upstream TRUNCATE: :halt (fail-closed, default) or :mirror (raw-delete the mirror rows in-txn).

replicant_options(dsl_or_extended)

@spec replicant_options(dsl_or_extended :: module() | map()) :: %{
  required(atom()) => any()
}

replicant DSL options

Returns a map containing the and any configured or default values.

replicant_skip(dsl_or_extended)

@spec replicant_skip(dsl_or_extended :: module() | map()) :: {:ok, [atom()]} | :error

Source non-identity columns excluded from the mirror write. Must NOT name the primary key — a dropped PK would forge a fresh vertex identity on every apply, so a skipped PK is rejected at compile by ValidatePrimaryKeyNotSkipped.

replicant_skip!(dsl_or_extended)

@spec replicant_skip!(dsl_or_extended :: module() | map()) :: [atom()] | no_return()

Source non-identity columns excluded from the mirror write. Must NOT name the primary key — a dropped PK would forge a fresh vertex identity on every apply, so a skipped PK is rejected at compile by ValidatePrimaryKeyNotSkipped.

replicant_source_schema(dsl_or_extended)

@spec replicant_source_schema(dsl_or_extended :: module() | map()) ::
  {:ok, String.t()} | :error

Source Postgres schema name.

replicant_source_schema!(dsl_or_extended)

@spec replicant_source_schema!(dsl_or_extended :: module() | map()) ::
  String.t() | no_return()

Source Postgres schema name.

replicant_source_table(dsl_or_extended)

@spec replicant_source_table(dsl_or_extended :: module() | map()) ::
  {:ok, String.t()} | :error

Source Postgres table name. Required — a graph resource's own arcade label is not its Postgres source table, so no reflection fallback is offered.

replicant_source_table!(dsl_or_extended)

@spec replicant_source_table!(dsl_or_extended :: module() | map()) ::
  String.t() | no_return()

Source Postgres table name. Required — a graph resource's own arcade label is not its Postgres source table, so no reflection fallback is offered.

replicant_tenant_attribute(dsl_or_extended)

@spec replicant_tenant_attribute(dsl_or_extended :: module() | map()) ::
  {:ok, atom()} | :error

Source column carrying the tenant. Resolved per row and passed as tenant: to the mirror action. Requires the source table to be REPLICA IDENTITY FULL: a :delete / PK-changing :update resolves the tenant from old_record, which is key-only under the default replica identity — the tenant column would be absent, so the apply fails closed :tenant_required and halts the whole transaction.

replicant_tenant_attribute!(dsl_or_extended)

@spec replicant_tenant_attribute!(dsl_or_extended :: module() | map()) ::
  atom() | no_return()

Source column carrying the tenant. Resolved per row and passed as tenant: to the mirror action. Requires the source table to be REPLICA IDENTITY FULL: a :delete / PK-changing :update resolves the tenant from old_record, which is key-only under the default replica identity — the tenant column would be absent, so the apply fails closed :tenant_required and halts the whole transaction.

skip(resource)

@spec skip(Ash.Resource.t()) :: [atom()]

Source columns excluded from the mirror write, else [] when undeclared.

source_schema(resource)

@spec source_schema(Ash.Resource.t()) :: String.t()

The source Postgres schema for the resource: the explicit source_schema, else "public".

source_table(resource)

@spec source_table(Ash.Resource.t()) :: String.t()

The source Postgres table for the resource. Required — no reflection fallback.

tenant_attribute(resource)

@spec tenant_attribute(Ash.Resource.t()) :: atom() | nil

The source column carrying the tenant, else nil when undeclared.