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
impl NodeHandle
Sourcepub fn send(&self, to: &Address, event: Event) -> Result<String, DeliveryError>
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.
Sourcepub fn send_envelope(&self, env: Envelope) -> Result<(), DeliveryError>
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.
Sourcepub async fn ask(
&self,
to: &Address,
event: Event,
timeout: Duration,
) -> Result<Event, AskError>
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.
Sourcepub fn register_resolver(&self, scheme: &str, resolver: Arc<dyn Resolver>)
pub fn register_resolver(&self, scheme: &str, resolver: Arc<dyn Resolver>)
Registers a resolver for addresses of scheme.
Sourcepub fn bind_address(&self, address: &Address, chart_type: &str, key: &str)
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.
Sourcepub fn notify(&self, a: &Address) -> bool
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.
Sourcepub fn wakeup(&self) -> BoxFuture<()>
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.
Sourcepub fn deliver_here(&self, env: Envelope) -> Result<(), DeliveryError>
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.
Sourcepub fn record_dead_letter(
&self,
receiver: &Address,
env: &Envelope,
reason: &str,
)
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.