pub enum Command {
Pause,
Resume,
ExitWithSuccess,
Quit,
Nudge,
}Expand description
Commands are messages that can be send to control the behavior of an actor.
They are similar to UNIX signals.
They are treated with a higher priority than regular actor messages.
Variants§
Pause
Temporarily pauses the actor. A paused actor only checks on its high priority channel and still shows “progress”. It appears as healthy to the supervisor.
Scheduled message are still processed.
Semantically, it is similar to SIGSTOP.
Resume
Resume a paused actor. If the actor was not paused this command has no effects.
Semantically, it is similar to SIGCONT.
ExitWithSuccess
Stops the actor with a success exit status code.
Upstream actors that terminates should send the ExitWithSuccess
command to downstream actors to inform them that there are no more
incoming messages.
It is similar to Quit, except for the resulting exit status.
Quit
Asks the actor to gracefully shutdown.
The actor will stop processing messages and its finalize function will be called.
The exit status is then ActorExitStatus::Quit.
This is the equivalent of sending SIGINT/Ctrl-C to a process.
Nudge
Nudging is a No-op message.
Its only effect is to wake-up actors that are stuck waiting for a message.
This is useful to kill actors properly or for tests. Actors stuck waiting for a message do not have any timeout to check for their killswitch signal.
Note: Historically, actors used to have a timeout, then the wake up logic worked using a Kill command. However, after the introduction of supervision, it became common to recycle a mailbox.
After a panic for instance, the supervisor of an actor might kill it by activating its killswitch and sending a Kill message.
The respawned actor would receive its predecessor mailbox and possibly end up process a Kill message as its first message.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Command
impl RefUnwindSafe for Command
impl Send for Command
impl Sync for Command
impl Unpin for Command
impl UnwindSafe for Command
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<A> Handler<Command> for Awhere
A: Actor,
impl<A> Handler<Command> for Awhere
A: Actor,
Source§fn handle<'life0, 'life1, 'async_trait>(
&'life0 mut self,
command: Command,
ctx: &'life1 ActorContext<A>,
) -> Pin<Box<dyn Future<Output = Result<<A as Handler<Command>>::Reply, ActorExitStatus>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
A: 'async_trait,
fn handle<'life0, 'life1, 'async_trait>(
&'life0 mut self,
command: Command,
ctx: &'life1 ActorContext<A>,
) -> Pin<Box<dyn Future<Output = Result<<A as Handler<Command>>::Reply, ActorExitStatus>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
A: 'async_trait,
and its exit status will be the one defined in the error.