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

Link to this section Functions

Link to this function child_spec(arg)

See start_link/2 for options.

Link to this function count_children(supervisor)

Works like Supervisor.count_children/1.

This function delegates to all supervisors in the cluster and returns the aggregated output.

Link to this function delete_child(supervisor, child_id)

Works like Supervisor.delete_child/2

Link to this function restart_child(supervisor, child_id)

Works like Supervisor.restart_child/2

Link to this function start_child(supervisor, child_spec)

Works like Supervisor.start_child/2.

Link to this function start_link(children, options)

Works like Supervisor.start_link. Extra options are documented here:

Link to this function stop(supervisor, reason, timeout \\ :infinity)

Works like Supervisor.stop/3.

Link to this function terminate_child(supervisor, child_id)

Works like Supervisor.terminate_child/2

Link to this function which_children(supervisor)

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.