distribute/monitor
Types
Process and node monitoring.
This module provides functions to monitor processes and nodes for failure detection.
Handling Monitor Messages
When a monitored process terminates, the monitoring process receives a message.
Since this library wraps Erlang primitives, the message format is an Erlang tuple:
{'DOWN', Reference, process, Pid, Reason}.
To handle this in Gleam, you typically need to use gleam/erlang/process with
a Selector that can match this message, or use a custom receiver.
Represents a process identifier.
pub type Pid
Values
pub fn demonitor(ref: Reference) -> Bool
Stop monitoring a process. Returns True if the monitor was found and removed.
pub fn monitor(pid: Pid) -> Reference
Monitor a process. Returns a monitor reference. When the monitored process terminates, a message of the form {‘DOWN’, Reference, process, Pid, Reason} is sent to the caller.
pub fn monitor_node(node: String, flag: Bool) -> Bool
Monitor a node for up/down events. Pass True to start monitoring, False to stop. Note: This function requires the current node to be distributed, otherwise it will raise a ‘notalive’ error.