pub struct ActorHandle<A: Actor> { /* private fields */ }Expand description
An Actor Handle serves as an address to communicate with an actor.
Implementations§
Source§impl<A: Actor> ActorHandle<A>
impl<A: Actor> ActorHandle<A>
pub fn state(&self) -> ActorState
Sourcepub async fn process_pending_and_observe(
&self,
) -> Observation<A::ObservableState>
pub async fn process_pending_and_observe( &self, ) -> Observation<A::ObservableState>
Process all of the pending messages, and returns a snapshot of the observable state of the actor after this.
This method is mostly useful for tests.
To actually observe the state of an actor for ops purpose,
prefer using the .observe() method.
This method timeout if reaching the end of the message takes more than an HEARTBEAT.
Sourcepub async fn observe(&self) -> Observation<A::ObservableState>
pub async fn observe(&self) -> Observation<A::ObservableState>
Observe the current state.
The observation will be scheduled as a high priority message, therefore it will be executed after the current active message and the current command queue have been processed.
Sourcepub fn pause(&self)
pub fn pause(&self)
Pauses the actor. The actor will stop processing messages from the low priority
channel, but its work can be resumed by calling the method .resume().
Sourcepub async fn kill(self) -> (ActorExitStatus, A::ObservableState)
pub async fn kill(self) -> (ActorExitStatus, A::ObservableState)
Kills the actor. Its finalize function will still be called.
This function also actionnates the actor kill switch.
The other difference with quit is the exit status. It is important, as the finalize logic may behave differently depending on the exit status.
Sourcepub async fn quit(self) -> (ActorExitStatus, A::ObservableState)
pub async fn quit(self) -> (ActorExitStatus, A::ObservableState)
Gracefully quit the actor, regardless of whether there are pending messages or not. Its finalize function will be called.
The kill switch is not actionated.
The other difference with kill is the exit status. It is important, as the finalize logic may behave differently depending on the exit status.
Sourcepub async fn join(self) -> (ActorExitStatus, A::ObservableState)
pub async fn join(self) -> (ActorExitStatus, A::ObservableState)
Waits until the actor exits by itself. This is the equivalent of Thread::join.
pub fn last_observation(&self) -> A::ObservableState
pub fn mailbox(&self) -> &Mailbox<A>
Trait Implementations§
Source§impl<A: Actor> Debug for ActorHandle<A>
impl<A: Actor> Debug for ActorHandle<A>
Source§impl<A: Actor> Supervisable for ActorHandle<A>
impl<A: Actor> Supervisable for ActorHandle<A>
Source§fn harvest_health(&self) -> Health
fn harvest_health(&self) -> Health
Harvests the health of the actor by checking its state (see ActorState) and/or progress
(see Progress). When the actor is running, calling this method resets its progress state
to “no update” (see ProgressState). As a consequence, only one supervisor or probe
should periodically invoke this method during the lifetime of the actor.