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 pause(&self)
pub async fn pause(&self)
Pauses the actor. The actor will stop processing the message, 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
.
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 command message, therefore it will be executed after the current active message and the current command queue have been processed.