Struct quickwit_actors::ActorContext
source · [−]pub struct ActorContext<A: Actor> { /* private fields */ }
Implementations
sourceimpl<A: Actor> ActorContext<A>
impl<A: Actor> ActorContext<A>
pub fn mailbox(&self) -> &Mailbox<A>
pub fn actor_instance_id(&self) -> &str
sourcepub fn protect_zone(&self) -> ProtectedZoneGuard
pub fn protect_zone(&self) -> ProtectedZoneGuard
This function returns a guard that prevents any supervisor from identifying the
actor as dead.
The protection ends when the ProtectZoneGuard
is dropped.
In an ideal world, you should never need to call this function. It is only useful in some corner cases, like calling a long blocking from an external library that you trust.
sourcepub fn kill_switch(&self) -> &KillSwitch
pub fn kill_switch(&self) -> &KillSwitch
Gets a copy of the actor kill switch. This should rarely be used.
For instance, when quitting from the process_message function, prefer simply
returning Error(ActorExitStatus::Failure(..))
pub fn progress(&self) -> &Progress
pub fn spawn_actor<SpawnedActor: Actor>(
&self,
actor: SpawnedActor
) -> SpawnBuilder<SpawnedActor>
sourcepub fn record_progress(&self)
pub fn record_progress(&self)
Records some progress.
This function is only useful when implementing actors that may take more than
HEARTBEAT
to process a single message.
In that case, you can call this function in the middle of the process_message method
to prevent the actor from being identified as blocked or dead.
sourceimpl<A: Actor> ActorContext<A>
impl<A: Actor> ActorContext<A>
sourcepub async fn send_message<DestActor: Actor, M>(
&self,
mailbox: &Mailbox<DestActor>,
msg: M
) -> Result<Receiver<DestActor::Reply>, SendError> where
DestActor: Handler<M>,
M: 'static + Send + Sync + Debug,
pub async fn send_message<DestActor: Actor, M>(
&self,
mailbox: &Mailbox<DestActor>,
msg: M
) -> Result<Receiver<DestActor::Reply>, SendError> where
DestActor: Handler<M>,
M: 'static + Send + Sync + Debug,
Posts a message in an actor’s mailbox.
This method does not wait for the message to be handled by the
target actor. However, it returns a oneshot receiver that the caller
that makes it possible to .await
it.
If the reply is important, chances are the .ask(...)
method is
more indicated.
Droppping the receiver channel will not cancel the processing of the messsage. It is a very common usage. In fact most actors are expected to send message in a fire-and-forget fashion.
Regular messages (as opposed to commands) are queued and guaranteed to be processed in FIFO order.
This method hides logic to prevent an actor from being identified as frozen if the destination actor channel is saturated, and we are simply experiencing back pressure.
pub async fn ask<DestActor: Actor, M, T>(
&self,
mailbox: &Mailbox<DestActor>,
msg: M
) -> Result<T, AskError<Infallible>> where
DestActor: Handler<M, Reply = T>,
M: 'static + Send + Sync + Debug,
sourcepub async fn ask_for_res<DestActor: Actor, M, T, E: Debug>(
&self,
mailbox: &Mailbox<DestActor>,
msg: M
) -> Result<T, AskError<E>> where
DestActor: Handler<M, Reply = Result<T, E>>,
M: 'static + Send + Sync + Debug,
pub async fn ask_for_res<DestActor: Actor, M, T, E: Debug>(
&self,
mailbox: &Mailbox<DestActor>,
msg: M
) -> Result<T, AskError<E>> where
DestActor: Handler<M, Reply = Result<T, E>>,
M: 'static + Send + Sync + Debug,
Similar to send_message
, except this method
waits asynchronously for the actor reply.
sourcepub async fn send_exit_with_success<Dest: Actor>(
&self,
mailbox: &Mailbox<Dest>
) -> Result<(), SendError>
pub async fn send_exit_with_success<Dest: Actor>(
&self,
mailbox: &Mailbox<Dest>
) -> Result<(), SendError>
Send the Success message to terminate the destination actor with the Success exit status.
The message is queued like any regular message, so that pending messages will be processed first.
sourcepub async fn send_self_message<M>(
&self,
msg: M
) -> Result<Receiver<A::Reply>, SendError> where
A: Handler<M>,
M: 'static + Sync + Send + Debug,
pub async fn send_self_message<M>(
&self,
msg: M
) -> Result<Receiver<A::Reply>, SendError> where
A: Handler<M>,
M: 'static + Sync + Send + Debug,
async
version of send_self_message
.
pub async fn schedule_self_msg<M>(&self, after_duration: Duration, msg: M) where
A: Handler<M>,
M: 'static + Send + Sync + Debug,
Trait Implementations
sourceimpl<A: Actor> Clone for ActorContext<A>
impl<A: Actor> Clone for ActorContext<A>
Auto Trait Implementations
impl<A> RefUnwindSafe for ActorContext<A> where
A: RefUnwindSafe,
impl<A> Send for ActorContext<A>
impl<A> Sync for ActorContext<A>
impl<A> Unpin for ActorContext<A> where
A: Unpin,
impl<A> UnwindSafe for ActorContext<A> where
A: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more