horde v0.1.3 Horde.Supervisor
A distributed supervisor
Horde.Supervisor implements a distributed Supervisor backed by a add-wins last-write-wins δ-CRDT (provided by DeltaCrdt.AWLWWMap
). This CRDT is used for both tracking membership of the cluster and tracking supervised processes.
Using CRDTs guarantees that the distributed, shared state will eventually converge. It also means that Horde.Supervisor is eventually-consistent, and is optimized for availability and partition tolerance. This can result in temporary inconsistencies under certain conditions (when cluster membership is changing, for example).
Cluster membership is managed with Horde.Cluster
. Joining and leaving a cluster can be done with Horde.Cluster.join_hordes/2
and leaving is done with Horde.Cluster.leave_hordes/1
.
Each Horde.Supervisor node wraps its own local instance of Supervisor
. Horde.Supervisor.start_child/2
(for example) delegates to the local instance of Supervisor to actually start and monitor the child. The child spec is also written into the processes CRDT, along with a reference to the node on which it is running. When there is an update to the processes CRDT, Horde makes a comparison and corrects any inconsistencies (for example, if a conflict has been resolved and there is a process that no longer should be running on its node, it will kill that process and remove it from the local supervisor). So while most functions map 1:1 to the equivalent Supervisor functions, the eventually consistent nature of Horde requires extra behaviour not present in Supervisor.
Link to this section Summary
Functions
See start_link/2
for options
Works like Supervisor.start_link
. Extra options are documented here:
:distribution_strategy
, defaults toHorde.UniformDistribution
but can also be set toHorde.UniformQuorumDistribution
.Horde.UniformQuorumDistribution
enforces a quorum and will shut down all processes on a node if it is split from the rest of the cluster
Link to this section Functions
See start_link/2
for options.
Works like Supervisor.count_children/1
.
This function delegates to all supervisors in the cluster and returns the aggregated output.
Works like Supervisor.delete_child/2
Works like Supervisor.restart_child/2
Works like Supervisor.start_child/2
.
Works like Supervisor.start_link
. Extra options are documented here:
:distribution_strategy
, defaults toHorde.UniformDistribution
but can also be set toHorde.UniformQuorumDistribution
.Horde.UniformQuorumDistribution
enforces a quorum and will shut down all processes on a node if it is split from the rest of the cluster.
Works like Supervisor.stop/3
.
Works like Supervisor.terminate_child/2
Works like Supervisor.which_children/1
.
This function delegates to all supervisors in the cluster and returns the aggregated output. Where memory warnings apply to Supervisor.which_children
, these count double for Horde.Supervisor.which_children
.