Skip to main content

Module node

Module node 

Source
Expand description

A runtime node: activations, turns, the outbox, timers, supervision and migrations.

A Node owns the in-memory activations of one process. Its scheduler is synchronous and deterministic: Node::pump drains finished background turns, fires due timers, runs one turn for every actor with a deliverable message and deactivates idle actors; Node::run_until_idle pumps until nothing is left to do at the current time, and Node::run is the async loop that sleeps until the next timer or wake-up. Datamodels need not be Send, so a node stays on one thread (tokio::task::LocalSet); everything outside it talks to it through a NodeHandle, which is Send + Sync.

One turn of a virtual actor:

  1. receive the oldest message not deferred by the active states;
  2. drop it if its message id is already journaled, if it is a second reply to a request, or if it is a timer that was cancelled;
  3. stamp the time, run the start macrostep (first entry only) and one macrostep;
  4. append the entry with compare-and-set at the expected position, carrying the current-state delta and the fencing token; on a conflict step down without dispatching;
  5. acknowledge the message, then dispatch the recorded sends (the outbox), arm timers, start and cancel invocations, record dead letters, and write a snapshot every N entries.

Structs§

ActorState
An actor’s state at a journal position.
DeadLetter
A recorded dead letter.
Node
A runtime node. See the module documentation.
NodeBuilder
Builds a Node.
NodeConfig
Node settings.
NodeHandle
A handle on a node for callers outside the actor system: send, ask, register resolvers, shut down. It is Send + Sync and cheap to clone.
NodeStats
Counters for observing a node.

Enums§

ActivationError
Why an actor could not be activated.
AskError
Why an external ask failed.
CrashPoint
Where a node simulates a crash (for tests of the journal protocol): the node stops at that point of the next turn and does nothing afterwards, as if the process died.
DeliveryError
Why a message could not be delivered.
MigrateError
Why a migration or fork was refused.
RemoveError
Why a chart version could not be removed.