libcluster v2.0.3 Cluster.Strategy behaviour

This module defines the behaviour for implementing clustering strategies.

Summary

Functions

Given a list of node names, attempts to connect to all of them. Returns :ok if all nodes connected, or {:error, [{node, reason}, ..]} if we failed to connect to some nodes

Given a list of node names, attempts to disconnect from all of them. Returns :ok if all nodes disconnected, or {:error, [{node, reason}, ..]} if we failed to disconnect from some nodes

Types

bad_nodes :: [{node, reason :: term}]
mfa_tuple :: {module, atom, [term]}
strategy_opts :: [topology: atom, connect: mfa_tuple, disconnect: mfa_tuple]
topology :: atom

Functions

connect_nodes(topology, arg, nodes)

Specs

connect_nodes(topology, mfa_tuple, [atom]) ::
  :ok |
  {:error, bad_nodes}

Given a list of node names, attempts to connect to all of them. Returns :ok if all nodes connected, or {:error, [{node, reason}, ..]} if we failed to connect to some nodes.

All failures are logged.

disconnect_nodes(topology, arg, nodes)

Specs

disconnect_nodes(topology, mfa_tuple, [atom]) ::
  :ok |
  {:error, bad_nodes}

Given a list of node names, attempts to disconnect from all of them. Returns :ok if all nodes disconnected, or {:error, [{node, reason}, ..]} if we failed to disconnect from some nodes.

All failures are logged.

Callbacks

start_link(strategy_opts)

Specs

start_link(strategy_opts) ::
  {:ok, pid} |
  :ignore |
  {:error, reason :: term}