Skip to main content

Node

Struct Node 

Source
pub struct Node { /* private fields */ }
Expand description

A runtime node. See the module documentation.

Implementations§

Source§

impl Node

Source

pub fn builder(storage: Arc<dyn Storage>, shell: Shell) -> NodeBuilder

A builder for a node on storage with the shell services shell.

Source

pub fn handle(&self) -> NodeHandle

A handle for callers outside the actor system.

Source

pub fn stats(&self) -> &NodeStats

Counters.

Source

pub fn storage(&self) -> &Arc<dyn Storage> ⓘ

The storage.

Source

pub fn now_ms(&self) -> i64

The node’s clock reading.

Source

pub fn is_active(&self, a: &Address) -> bool

Whether a has an activation on this node.

Source

pub fn activate_actor(&mut self, a: &Address) -> Result<(), ActivationError>

Activates virtual actor a now, without waiting for a message (a no-op when active).

§Errors

ActivationError when its journal cannot be replayed.

Source

pub fn last_error(&self, a: &Address) -> Option<&ActivationError>

The last activation error of a.

Source

pub fn chart(&self, iri: &str) -> Option<Arc<ChartInfo>>

The registered chart version iri.

Source

pub fn latest(&self, ty: &str) -> Option<Arc<ChartInfo>>

The latest version of chart type ty.

Source

pub fn mailbox(&self, a: &Address) -> Vec<Envelope>

The messages waiting for a, in order.

Source

pub fn register_type( &mut self, chart_type: &str, chart: Chart, ) -> Result<ChartVersion, RegisterError>

Registers chart as the latest version of chart type chart_type; virtual actors addressed <chart_type>/<key> run it. Existing actors keep their version.

§Errors

RegisterError when the type is not an IRI, the chart is invalid, or an <invoke> targets a virtual actor.

Source

pub fn register_chart( &mut self, chart: Chart, ) -> Result<ChartVersion, RegisterError>

Registers a chart version without a type (for invoked charts and migrations).

§Errors

RegisterError when the chart is invalid or its datamodel refuses it.

Source

pub fn register_migration(&mut self, m: Migration)

Declares a migration.

Source

pub fn register_actor_kind(&mut self, invoke_type: &str, factory: ActorFactory)

Registers an actor kind that <invoke type="..."> can start.

Source

pub fn register_worker( &mut self, address: Address, pool: usize, handler: ActorFn, )

Registers a pool of pool stateless workers at address, each running handler.

Source

pub fn send(&self, to: &Address, event: Event) -> Result<String, DeliveryError>

Sends event to to from outside the actor system.

§Errors

DeliveryError when to cannot be resolved.

Source

pub fn send_envelope(&self, env: Envelope) -> Result<(), DeliveryError>

Delivers a complete envelope.

§Errors

DeliveryError when its receiver cannot be resolved.

Source

pub fn remove_version(&mut self, iri: &str) -> Result<(), RemoveError>

Removes chart version iri, unless a non-final actor still uses it.

§Errors

RemoveError::InUse listing those actors.

Source

pub fn pump(&mut self) -> bool

One scheduling round; true when anything happened.

Source

pub fn run_until_idle(&mut self) -> usize

Pumps until nothing is left to do at the current time; returns the rounds that did something.

Source

pub async fn settle(&mut self)

Runs until idle and no background turn is running.

Source

pub async fn run(&mut self)

The node’s event loop: runs until idle, then sleeps until the next timer, idle deadline or wake-up, until NodeHandle::shutdown.

Source

pub fn next_deadline(&self) -> Option<i64>

The earliest time something is due (a timer, a failed actor’s back-off, an idle deadline), for shells that drive the node with Node::run_until_idle themselves.

Source§

impl Node

Source

pub fn dead_letters( &self, receiver: &Address, ) -> Result<Vec<DeadLetter>, StoreError>

The dead letters recorded for receiver, by SPARQL over its dead-letter graph.

§Errors

The store’s query errors.

Source

pub fn deactivate(&mut self, a: &Address)

Deactivates a, keeping its mailbox: its state is recoverable from the journal.

Source

pub fn active_actors(&self) -> Vec<Address>

The virtual actors active on this node.

Source

pub fn drain(&mut self, which: &dyn Fn(&Address) -> bool) -> Vec<Address>

Drains the virtual actors which selects, for a shard handover: runs until idle (every macrostep in progress finishes and its outbox is dispatched), then deactivates them. Returns the actors deactivated. Their messages that arrive afterwards follow the placement.

Source

pub fn migrate( &mut self, a: &Address, migration: &str, ) -> Result<u64, MigrateError>

Migrates actor a with the declared migration migration: checks that every reachable configuration of the old version is mapped, transforms the datamodel and appends one migration entry holding the snapshot before, the migration IRI and the snapshot after. Nothing is appended when any step fails.

§Errors

MigrateError.

Source

pub fn fork( &mut self, source: &Address, position: u64, new: &Address, ) -> Result<(), MigrateError>

Forks source at position under new: the new actor’s journal starts with a fork entry referencing the source and holding its state there; the source is unchanged.

§Errors

MigrateError::Exists when new has a journal, or replay errors.

Source

pub fn state_at( &mut self, a: &Address, position: u64, ) -> Result<ActorState, ActivationError>

The state of a after journal position position, rebuilt by replay; the live actor and the journal are not touched.

§Errors

ActivationError when the journal cannot be replayed.

Source

pub fn state(&mut self, a: &Address) -> Result<ActorState, ActivationError>

The current state of a: the live activation’s, or rebuilt by replay.

§Errors

ActivationError when the journal cannot be replayed.

Source

pub fn can( &mut self, a: &Address, event: &Event, ) -> Result<bool, ActivationError>

Whether a would accept event in its current configuration: the event enables at least one transition or an active state defers it. Guards are evaluated on a copy of the datamodel; nothing changes and nothing is journaled. An actor without a journal has no configuration yet and accepts nothing.

§Errors

ActivationError when the journal cannot be replayed.

Source

pub fn journal(&self, a: &Address) -> Result<Vec<EntryData>, ActivationError>

The decoded journal of a.

§Errors

Store or decoding errors.

Source

pub fn pending_timers(&self) -> Vec<(i64, TimerRecord)>

The pending durable timers armed on this node, in due order.

Source

pub fn datamodels(&self) -> &Arc<dyn DatamodelRegistry + Send + Sync> ⓘ

The datamodel registry.

Source

pub fn fresh_id(&self, prefix: &str) -> String

A fresh, unique id with prefix.

Source

pub fn short_hex(text: &str) -> String

The digest of text as short hex (exposed for tests and tools).

Trait Implementations§

Source§

impl Debug for Node

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Node

§

impl !Send for Node

§

impl !Sync for Node

§

impl !UnwindSafe for Node

§

impl Forget for Node

§

impl Freeze for Node

§

impl Move for Node

§

impl Unpin for Node

§

impl UnsafeUnpin for Node

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V