Cantrip.Cluster (Cantrip v1.3.3)

Copy Markdown View Source

When you want a Familiar's loom replicated across BEAM nodes, connect the nodes with normal BEAM tooling first, then use these helpers to wire Mnesia across them.

Helpers for explicit BEAM-cluster setup.

Cantrip does not perform cluster discovery. Operators still use the normal BEAM tools (--name / --sname, cookies, Node.connect/1, libcluster, Kubernetes headless services, etc.). This module covers the Cantrip-specific handoff once nodes are connected: make Mnesia aware of extra DB nodes and replicate loom tables across them.

Summary

Functions

Connects Mnesia to already-connected DB nodes.

Replicates a Mnesia loom table to the given nodes.

Types

copy_type()

@type copy_type() :: :disc_copies | :ram_copies

Functions

connect_mnesia(nodes, opts \\ [])

@spec connect_mnesia(
  [node()],
  keyword()
) :: {:ok, [node()]} | {:error, term()}

Connects Mnesia to already-connected DB nodes.

Returns {:ok, connected_nodes} using Mnesia's change_config(:extra_db_nodes, nodes) result. This intentionally does not discover or connect distributed Erlang nodes; do that before calling this.

replicate_table(table, nodes, opts \\ [])

@spec replicate_table(atom(), [node()], keyword()) :: :ok | {:error, term()}

Replicates a Mnesia loom table to the given nodes.

The local node is converted to copy_type via change_table_copy_type/3; remote nodes are added via add_table_copy/3. Existing copies are treated as success.