pub struct Node { /* private fields */ }Expand description
A runtime node. See the module documentation.
Implementations§
Source§impl Node
impl Node
Sourcepub fn builder(storage: Arc<dyn Storage>, shell: Shell) -> NodeBuilder
pub fn builder(storage: Arc<dyn Storage>, shell: Shell) -> NodeBuilder
A builder for a node on storage with the shell services shell.
Sourcepub fn handle(&self) -> NodeHandle
pub fn handle(&self) -> NodeHandle
A handle for callers outside the actor system.
Sourcepub fn activate_actor(&mut self, a: &Address) -> Result<(), ActivationError>
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.
Sourcepub fn last_error(&self, a: &Address) -> Option<&ActivationError>
pub fn last_error(&self, a: &Address) -> Option<&ActivationError>
The last activation error of a.
Sourcepub fn register_type(
&mut self,
chart_type: &str,
chart: Chart,
) -> Result<ChartVersion, RegisterError>
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.
Sourcepub fn register_chart(
&mut self,
chart: Chart,
) -> Result<ChartVersion, RegisterError>
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.
Sourcepub fn register_migration(&mut self, m: Migration)
pub fn register_migration(&mut self, m: Migration)
Declares a migration.
Sourcepub fn register_actor_kind(&mut self, invoke_type: &str, factory: ActorFactory)
pub fn register_actor_kind(&mut self, invoke_type: &str, factory: ActorFactory)
Registers an actor kind that <invoke type="..."> can start.
Sourcepub fn register_worker(
&mut self,
address: Address,
pool: usize,
handler: ActorFn,
)
pub fn register_worker( &mut self, address: Address, pool: usize, handler: ActorFn, )
Registers a pool of pool stateless workers at address, each running handler.
Sourcepub fn send_envelope(&self, env: Envelope) -> Result<(), DeliveryError>
pub fn send_envelope(&self, env: Envelope) -> Result<(), DeliveryError>
Sourcepub fn remove_version(&mut self, iri: &str) -> Result<(), RemoveError>
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.
Sourcepub fn run_until_idle(&mut self) -> usize
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.
Sourcepub async fn run(&mut self)
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.
Sourcepub fn next_deadline(&self) -> Option<i64>
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
impl Node
Sourcepub fn dead_letters(
&self,
receiver: &Address,
) -> Result<Vec<DeadLetter>, StoreError>
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.
Sourcepub fn deactivate(&mut self, a: &Address)
pub fn deactivate(&mut self, a: &Address)
Deactivates a, keeping its mailbox: its state is recoverable from the journal.
Sourcepub fn active_actors(&self) -> Vec<Address>
pub fn active_actors(&self) -> Vec<Address>
The virtual actors active on this node.
Sourcepub fn drain(&mut self, which: &dyn Fn(&Address) -> bool) -> Vec<Address>
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.
Sourcepub fn migrate(
&mut self,
a: &Address,
migration: &str,
) -> Result<u64, MigrateError>
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
Sourcepub fn fork(
&mut self,
source: &Address,
position: u64,
new: &Address,
) -> Result<(), MigrateError>
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.
Sourcepub fn state_at(
&mut self,
a: &Address,
position: u64,
) -> Result<ActorState, ActivationError>
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.
Sourcepub fn state(&mut self, a: &Address) -> Result<ActorState, ActivationError>
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.
Sourcepub fn can(
&mut self,
a: &Address,
event: &Event,
) -> Result<bool, ActivationError>
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.
Sourcepub fn pending_timers(&self) -> Vec<(i64, TimerRecord)>
pub fn pending_timers(&self) -> Vec<(i64, TimerRecord)>
The pending durable timers armed on this node, in due order.
Sourcepub fn datamodels(&self) -> &Arc<dyn DatamodelRegistry + Send + Sync> ⓘ
pub fn datamodels(&self) -> &Arc<dyn DatamodelRegistry + Send + Sync> ⓘ
The datamodel registry.