ClusterHelper.RemoteSync behaviour (ClusterHelper v1.0.0)

Copy Markdown View Source

Behaviour for remote Erlang RPC operations used in cluster synchronisation.

Implementations handle generation checks and full role pulls from remote nodes. The configured adapter is resolved via ClusterHelper.Adapter.

Built-in adapters

Custom adapters

defmodule MyApp.MyRemoteSync do
  @behaviour ClusterHelper.RemoteSync

  @impl true
  def get_remote_generation(node, scope), do: ...
  @impl true
  def pull_roles_from_node(scope, node, opts \ []), do: ...
  @impl true
  def get_remote_scopes(node), do: ...
end

Summary

Callbacks

Gets the generation counter from a remote node for a given scope.

Gets scopes from a remote node.

Performs a full role pull from a remote node.

Functions

Gets the generation counter (delegates to configured adapter).

Gets scopes from a remote node (delegates to configured adapter).

Pulls roles from a remote node (delegates to configured adapter).

Callbacks

get_remote_generation(node, atom)

@callback get_remote_generation(node(), atom()) :: {:ok, integer()} | {:error, term()}

Gets the generation counter from a remote node for a given scope.

Returns {:ok, integer} on success, {:error, reason} on failure.

get_remote_scopes(node)

@callback get_remote_scopes(node()) :: {:ok, [atom()]} | {:error, term()}

Gets scopes from a remote node.

Returns {:ok, scopes} on success, {:error, reason} on failure.

pull_roles_from_node(atom, node, keyword)

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

Performs a full role pull from a remote node.

Returns {:ok, roles} on success, {:error, reason} on failure.

Functions

get_remote_generation(node, scope)

@spec get_remote_generation(node(), atom()) :: {:ok, integer()} | {:error, term()}

Gets the generation counter (delegates to configured adapter).

get_remote_scopes(node)

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

Gets scopes from a remote node (delegates to configured adapter).

pull_roles_from_node(scope, node, opts \\ [])

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

Pulls roles from a remote node (delegates to configured adapter).