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

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

FailFast

Return Partition immediately when the route is unavailable or suspect.

Deadline

Retry until the caller deadline, then return Timeout or Partition.

MonitorLost

Resolve monitor and supervision partitions as MonitorLost.

CrashLinked

Opt in to cross-node link and supervision fail-together behavior.

Quarantine

Stop 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

Stopped

The monitored actor completed a graceful stop.

Terminated

The monitored actor was forcefully terminated.

Crashed(CrashKind)

The monitored actor crashed.

MonitorLost

The remote actor became unreachable.

LocalShutdown

The 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.