Skip to main content

NodeHandle

Struct NodeHandle 

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

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.

Implementations§

Source§

impl NodeHandle

Source

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

Sends event to to from outside the actor system; returns the message id.

§Errors

DeliveryError when to cannot be resolved.

Source

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

Delivers a complete envelope (with its own message id).

§Errors

DeliveryError when its receiver cannot be resolved.

Source

pub async fn ask( &self, to: &Address, event: Event, timeout: Duration, ) -> Result<Event, AskError>

Sends event to to and waits for its vt:reply, at most timeout on the node’s clock. For callers outside the actor system only (HTTP handlers, tests); charts never block. A reply arriving after the timeout is dropped.

§Errors

AskError::Timeout, or AskError::Delivery when to cannot be resolved.

Source

pub fn register_resolver(&self, scheme: &str, resolver: Arc<dyn Resolver>)

Registers a resolver for addresses of scheme.

Source

pub fn bind_address(&self, address: &Address, chart_type: &str, key: &str)

Binds address to the virtual actor of chart_type with key: the actor is hosted here and activated on message like <chart_type>/<key>, with address as its subject. Used for actors whose address is a DID.

Source

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

Tells the node that the mailbox of the local actor a received messages from outside the node (a relay pickup), so the actor is activated and receives them. False when a is not hosted here.

Source

pub fn shutdown(&self)

Asks Node::run to return.

Source

pub fn now_ms(&self) -> i64

The node’s clock reading.

Source

pub fn wakeup(&self) -> BoxFuture<()>

Completes once the node has new work (a delivered message, a finished background turn, a shutdown request), for shells that drive the node with Node::run_until_idle. A signal sent while nobody waits is kept for the next waiter.

Source

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

Delivers env to an actor hosted on this node without asking the placement: what a cluster does with a message another node sent here for an actor this node owns.

§Errors

DeliveryError when its receiver cannot be resolved.

Source

pub fn record_dead_letter( &self, receiver: &Address, env: &Envelope, reason: &str, )

Records env in receiver’s dead-letter graph with reason, at the node’s time.

Source

pub fn pending(&self, a: &Address) -> usize

The number of messages waiting in the local mailbox of a (none when a has no mailbox here).

Trait Implementations§

Source§

impl Clone for NodeHandle

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for NodeHandle

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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