Behaviour for cluster-wide messaging.
Implementations handle the mechanics of delivering messages to all nodes
in a scope. The configured adapter is resolved via ClusterHelper.Adapter.
Built-in adapters
ClusterHelper.Broadcast.PG— Erlang:pgprocess groups (default)
Custom adapters
defmodule MyApp.MyBroadcast do
@behaviour ClusterHelper.Broadcast
@impl true
def start_scope(scope), do: ...
@impl true
def join(scope), do: ...
@impl true
def leave(scope), do: ...
@impl true
def broadcast(scope, message), do: ...
endThen configure it:
config :cluster_helper, ClusterHelper.Adapter,
broadcast: MyApp.MyBroadcast
Summary
Callbacks
Sends a message to every other member of the scope.
Joins the current process to the scope's group.
Leaves the current process from the scope's group.
Ensures the messaging scope is initialized.
Functions
Broadcasts a message (delegates to configured adapter).
Joins the current process (delegates to configured adapter).
Leaves the current process (delegates to configured adapter).
Ensures a scope is started (delegates to configured adapter).
Callbacks
Sends a message to every other member of the scope.
@callback join(scope :: atom()) :: :ok
Joins the current process to the scope's group.
@callback leave(scope :: atom()) :: :ok
Leaves the current process from the scope's group.
@callback start_scope(scope :: atom()) :: :ok
Ensures the messaging scope is initialized.
Functions
Broadcasts a message (delegates to configured adapter).
@spec join(atom()) :: :ok
Joins the current process (delegates to configured adapter).
@spec leave(atom()) :: :ok
Leaves the current process (delegates to configured adapter).
@spec start_scope(atom()) :: :ok
Ensures a scope is started (delegates to configured adapter).