Module std.link_monitor
Actor monitor and link handle helpers.
Import MonitorRef from this module to name the owned registration returned
by monitor(actor) -> Result<MonitorRef, LinkError>. Its consuming close
removes the subscription; ordinary resource cleanup closes it at scope exit.
LinkError is available from the prelude; local and remote monitors share it.
Observing an occupied supervised actor role selects its current incarnation;
an empty role reports its stable token immediately and does not observe a
later replacement.
Contents
- fn set_partition_policy
- enum PartitionPolicy
- struct MonitorId
- enum DownReason
- struct DownNotification
- struct MonitorRef
- enum PartitionPolicyError
- inherent methods
Functions
Function set_partition_policy
pub fn set_partition_policy(policy: PartitionPolicy) -> () fails PartitionPolicyError
Select the partition-resolution policy for the current dispatch.
The policy governs how the remote send/ask failure path resolves a
route that is unavailable or suspect (see PartitionPolicy). It is scoped
to the current execution context — the dispatch of one actor message — so a
handler can choose a policy for the remote calls it is about to make.
Fails when called outside an actor dispatch, where a partition policy has no execution context to apply to.
The tag mapping is exhaustive: every PartitionPolicy variant maps to the
runtime discriminant it mirrors (execution_context.PartitionPolicy). A
new variant is a compile error here until it is mapped, so the surface can
never silently send an unmapped policy.
Types
Enum PartitionPolicy
Policy for resolving actor operations across network partitions.
Variants
FailFastReturn
Partitionimmediately when the route is unavailable or suspect.DeadlineRetry until the caller deadline, then return
TimeoutorPartition.MonitorLostResolve monitor and supervision partitions as
MonitorLost.CrashLinkedOpt in to cross-node link and supervision fail-together behavior.
QuarantineStop sending to a suspect or dead peer until a fresh incarnation appears.
Struct MonitorId
Stable identifier for one monitor registration.
Fields
- value: u64
Enum DownReason
Terminal cause carried by a DOWN notification.
Variants
StoppedThe monitored actor completed a graceful stop.
TerminatedThe monitored actor was forcefully terminated.
Crashed(CrashKind)The monitored actor crashed.
MonitorLostThe remote actor became unreachable.
LocalShutdownThe local node shut down before observation completed.
Struct DownNotification
Typed payload delivered to an actor's #[on(down)] hook.
Fields
- monitor: MonitorId
- target: DownTarget
Exact current incarnation, or stable local role token when vacant.
- reason: DownReason
Struct MonitorRef
A handle to an active monitor registration.
Fields
- ref_id: u64
Enum PartitionPolicyError
No actor dispatch is active for an execution-scoped policy change.
Variants
NoActorDispatch
Inherent methods
impl MonitorRef
fn id(self) -> MonitorId
Return this registration's stable monitor id without consuming the handle.
fn close(consume self)
Remove the monitor registration.
hew_actor_demonitor is idempotent for stale or already-swept ref_ids,
so actor-free close paths are safe at scope exit.