pub enum Command {
    Pause,
    Resume,
    ExitWithSuccess,
    Observe(Sender<Box<dyn Any + Send>>),
    Quit,
    Kill,
}
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.

Observe(Sender<Box<dyn Any + Send>>)

Asks the actor to update its ObservableState. Since it is a command, it will be treated with a higher priority than a normal message. If the actor is processing message, it will finish it, and the state observed will be the state after this message. The Observe command also ships a oneshot channel to allow client to wait on this observation.

The observation is then available using the ActorHander::last_observation() method.

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.

Kill

Kill the actor. The behavior is the same as if an actor detected that its kill switch was pushed.

It is similar to Quit, except the ActorExitState is different.

It can have important side effect, as the actor .finalize method may have different behavior depending on the exit state.

This is the equivalent of sending SIGKILL to a process.

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more