quickwit_actors

Struct ActorContext

Source
pub struct ActorContext<A: Actor> { /* private fields */ }

Implementations§

Source§

impl<A: Actor> ActorContext<A>

Source

pub fn mailbox(&self) -> &Mailbox<A>

Source

pub fn actor_instance_id(&self) -> &str

Source

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.

Source

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(..))

Source

pub fn progress(&self) -> &Progress

Source

pub fn spawn_actor<SpawnedActor: Actor>( &self, actor: SpawnedActor, ) -> SpawnBuilder<SpawnedActor>

Source

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.

Source§

impl<A: Actor> ActorContext<A>

Source

pub async fn send_message<DestActor, M>( &self, mailbox: &Mailbox<DestActor>, msg: M, ) -> Result<Receiver<DestActor::Reply>, SendError>
where DestActor: Handler<M> + Actor, 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.

Source

pub async fn ask<DestActor, M, T>( &self, mailbox: &Mailbox<DestActor>, msg: M, ) -> Result<T, AskError<Infallible>>
where DestActor: Handler<M, Reply = T> + Actor, M: 'static + Send + Sync + Debug,

Source

pub async fn ask_for_res<DestActor, M, T, E: Debug>( &self, mailbox: &Mailbox<DestActor>, msg: M, ) -> Result<T, AskError<E>>
where DestActor: Handler<M, Reply = Result<T, E>> + Actor, M: 'static + Send + Sync + Debug,

Similar to send_message, except this method waits asynchronously for the actor reply.

Source

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.

Source

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.

Source

pub async fn schedule_self_msg<M>(&self, after_duration: Duration, msg: M)
where A: Handler<M>, M: 'static + Send + Sync + Debug,

Trait Implementations§

Source§

impl<A: Actor> Clone for ActorContext<A>

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<A: Actor> Deref for ActorContext<A>

Source§

type Target = ActorContextInner<A>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

§

impl<A> Freeze for ActorContext<A>

§

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§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

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

fn in_current_span(self) -> Instrumented<Self>

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

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T