March Docs

DistLink

DistLink: cross-node process monitors and bidirectional links (P5c).

Monitor protocol (two-step):

  1. Local: call monitor(target_pid, timeout_ms) → sends MONITOR_REQ to
   the node that hosts target_pid, returns Ok(MonitorRef).
2. Remote node: receives MONITOR_REQ, calls march_dist_monitor_register
   in its C runtime.  On actor exit it sends MONITOR_FIRE back.
3. Local net-kernel loop: receives MONITOR_FIRE, delivers
   Down(ref, pid, reason) to the watcher's mailbox.

Node-down: when the peer connection drops (PeerDown from SwimDriver), the DistLink actor sweeps its pending_monitors table and fires Down(NodeDown) locally to all watchers of targets on that node.

Links build on monitors: both sides call monitor on each other. A Down message triggers EXIT propagation in the linked process (unless trapping).

Down reason: Normal | Killed | Crash(String) | NodeDown

MonitorRef is an opaque integer; demonitor(ref) cancels the monitor.

Types

typeDownReasonDownReason = Normal | Killed | Crash(String) | NodeDown#
typeMonitorRefMonitorRef = MonitorRef(Int)#
typePendingMonitorPendingMonitor = {#
typeMonitorTableMonitorTable = MonitorTable(Map(Int, PendingMonitor))#

Functions

fndecode_firedecode_fire(bytes : List(Int)) : Result((Int, DownReason), String)#
fndecode_reqdecode_req(bytes : List(Int)) : Result((String, Int, Int), String)#
fndown_msgdown_msg(m : PendingMonitor, reason : DownReason) : (MonitorRef, Int, DownReason)#
fnempty_tableempty_table() : MonitorTable do MonitorTable(Map.empty()) end#
fnencode_fireencode_fire(target_pid : Int, reason : DownReason) : List(Int)#
fnencode_reqencode_req(watcher_node : String, watcher_pid : Int, target_pid : Int) : List(Int)#
fnfind_by_target_pidfind_by_target_pid(tbl : MonitorTable, target_pid : Int) : Option(PendingMonitor)#
fninsert_monitorinsert_monitor(tbl : MonitorTable, m : PendingMonitor) : MonitorTable#
fnmake_monitormake_monitor(ref : MonitorRef, target_node : String, target_pid : Int,#
fnmonitors_on_nodemonitors_on_node(tbl : MonitorTable, node_id : String) : List(PendingMonitor)#
fnreason_of_tagreason_of_tag(tag : Int, msg : String) : DownReason#
fnremove_monitorremove_monitor(tbl : MonitorTable, ref : MonitorRef) : MonitorTable#
fntag_of_reasontag_of_reason(r : DownReason) : (Int, String)#