View Source Cloister (cloister v0.18.0)

Cloister is a consensus helper for clusters.

It is designed to be a configurable drop-in for transparent cluster support.

Supported options

  • :otp_app (atom/0) - OTP application this cloister runs for. The default value is :cloister.

  • :sentry - Required. The way the cloister knows how to build cluster; might be a service name or a node list. E. g. :"cloister.local" or ~w[c1@127.0.0.1 c2@127.0.0.1]a. Default [node()].

  • :consensus (non_neg_integer/0) - Required. Number of nodes to consider consensus. The default value is 1.

  • :listener (atom/0) - Listener to be called when the ring is changed. The default value is Cloister.Listener.Default.

  • :additional_modules - Additional modules to include into Cloister.Manager’s supervision tree.

  • :ring (atom/0) - The name of the HashRing to be used. If set, the HashRing is assumed to be managed externally.

  • :manager (non-empty keyword/0) - Set of options to configure Cloister.Manager when started in a supervision tree.

    • :name (atom/0) - Name of the Manager process.

    • :state (non-empty keyword/0) - The parameters to configure the Manager ouside of Cloister application.

      • :otp_app (atom/0) - Required.

      • :additional_modules

  • :monitor_opts (non-empty keyword/0) - Fine Cloister.Monitor’s tuning.

    • :name (atom/0) - Required. Name of the Monitor process.
  • :loopback? (boolean/0) - Use loopback interface in FQ node name? The default value is false.

  • :magic? - When false, allows to avoid node reinitialization The default value is :longnames.

Summary

Functions

Returns a specification to start this module under a supervisor.

Returns true if the hashring points to this node for the term given, false otherwise

Applies the function given as m, f, a on all the nodes given as a first parameter.

Returns the ring from current node cloister monitor state

Returns {:ok, node()} if the cloister has the only one sentry, or {:error, [node()] with the list of nodes fancied themselves a sentry.

See Cloister.Monitor.siblings!/0.

See Cloister.Monitor.siblings!/1.

The state of this cloister.

Retrieves states of all the nodes in the cloister.

Returns who would be chosen by a hash ring for the term in the group given

Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

@spec mine?(term :: any()) :: boolean() | {:error, :no_such_ring}

Returns true if the hashring points to this node for the term given, false otherwise

Link to this function

multiapply(nodes \\ nil, monitor \\ Cloister.Monitor, m, f, a)

View Source
@spec multiapply(nil | [node()], module(), module(), atom(), list()) :: any()

Applies the function given as m, f, a on all the nodes given as a first parameter.

If no nodes are given, it defaults to Cloister.siblings/0.

Link to this function

multicall(name, request)

View Source

See Cloister.Node.multicall/2.

Link to this function

multicall(nodes, name, request)

View Source

See Cloister.Node.multicall/3.

Link to this function

multicast(name, request)

View Source

See Cloister.Node.multicast/2.

Link to this function

multicast(nodes, name, request)

View Source

See Cloister.Node.multicast/3.

@spec ring() :: atom()

Returns the ring from current node cloister monitor state

Link to this function

sentry(monitor \\ Cloister.Monitor)

View Source
@spec sentry(monitor :: module()) :: {:ok, node()} | {:error, [node()]}

Returns {:ok, node()} if the cloister has the only one sentry, or {:error, [node()] with the list of nodes fancied themselves a sentry.

See Cloister.Monitor.siblings/0.

See Cloister.Monitor.siblings/1.

See Cloister.Monitor.siblings!/0.

See Cloister.Monitor.siblings!/1.

Link to this function

state(monitor \\ Cloister.Monitor)

View Source
@spec state(monitor :: module()) :: nil | Cloister.Monitor.t()

The state of this cloister.

This function returns the value only after Cloister.Monitor has been started

%Cloister.Monitor{
  otp_app: :rates_blender,
  consensus: 3,
  listener: MyApp.Cloister.Listener,
  monitor: Cloister.Monitor,
  started_at: ~U[2024-05-31 05:37:40.238027Z],
  alive?: true,
  clustered?: true,
  sentry?: false,
  ring: :my_app
}
Link to this function

states(monitor \\ Cloister.Monitor)

View Source
@spec states(monitor :: module()) :: {[Cloister.Monitor.t()], [node()]}

Retrieves states of all the nodes in the cloister.

Link to this function

whois(group \\ nil, term)

View Source
@spec whois(group :: atom(), term :: any()) ::
  node()
  | {:error, {:invalid_ring, :no_nodes}}
  | {:error, {:not_our_ring, atom()}}

Returns who would be chosen by a hash ring for the term in the group given