March Docs

DistSupervisor

DistSupervisor: a supervisor that manages children on remote cluster nodes (P5d).

Mirrors the local supervisor model but each child runs on a named remote node via NodeCall.call to its init function. The supervisor monitors each child with DistLink.monitor and applies the restart strategy when a Down arrives.

Restart strategies (matching local supervisor semantics): Permanent — always restart, regardless of exit reason. Transient — restart only on abnormal exit (Crash or Killed), not Normal. Temporary — never restart.

Supervision strategies (applied to the child set as a whole): OneForOne — restart only the failed child. OneForAll — restart all children when any one fails. RestForOne — restart the failed child and all children started after it.

Implementation note: the supervisor is a local actor. It spawns children via NodeCall.call, monitors them via DistLink.encode_req frames, and processes Down messages to restart as needed. The socket I/O and actor machinery are not eval-testable; only the pure restart-decision logic is tested here.

Types

typeRestartStrategyRestartStrategy = Permanent | Transient | Temporary#
typeSupervisionStrategySupervisionStrategy = OneForOne | OneForAll | RestForOne#
typeRemoteChildRemoteChild = {#
typeChildStateChildState = {#
typeStateState = {#

Functions

fnchild_countchild_count(s : State) : Int do List.length(s.children) end#
fnfind_child_by_reffind_child_by_ref(children : List(ChildState),#
fnlive_childrenlive_children(s : State) : List(ChildState) do s.children end#
fnmakemake(strat : SupervisionStrategy) : State#
fnrestart_indicesrestart_indices(strat : SupervisionStrategy, failed_idx : Int,#
fnshould_restartshould_restart(restart : RestartStrategy, reason : DistLink.DownReason) : Bool#
fnupdate_childupdate_child(children : List(ChildState), idx : Int,#