pub struct ActorMonitor { /* private fields */ }Expand description
A handle to a child actor that monitors another actor’s liveness.
Implementations§
Source§impl ActorMonitor
impl ActorMonitor
Sourcepub fn spawn_persistent<C>(cx: &C, target: ActorAddr) -> Selfwhere
C: Actor,
pub fn spawn_persistent<C>(cx: &C, target: ActorAddr) -> Selfwhere
C: Actor,
Spawn a persistent monitor actor for target as a child of cx.
A persistent monitor polls the target’s status for as long as it runs.
Sourcepub fn spawn_dormant<C>(cx: &C, target: ActorAddr) -> Selfwhere
C: Actor,
pub fn spawn_dormant<C>(cx: &C, target: ActorAddr) -> Selfwhere
C: Actor,
Spawn a monitor actor for target as a child of cx, starting dormant.
The monitor is active, polling the target’s status, while at least one
MonitorActivation from Self::activate is live, and dormant
otherwise. It receives the target’s terminal-status notification in
either state. This lets callers share one monitor across intermittent
waits without polling between them.
Sourcepub fn status(&self) -> MonitorStatus
pub fn status(&self) -> MonitorStatus
Return the monitor’s current status.
Sourcepub fn activate(&self, cx: &impl Actor) -> MonitorActivation
pub fn activate(&self, cx: &impl Actor) -> MonitorActivation
Keep the monitor active, polling the target’s status, until the returned activation is dropped.
Activations are counted; the monitor is active while any is live. When a dormant monitor becomes active, the first poll waits for the initial delay, so short-lived waits that the terminal-status notification resolves never poll. The monitor goes dormant at its first tick after the last activation is dropped and sends no further polls; reactivating it before then keeps its current poll schedule.
Sourcepub fn into_supervisor<C>(self, cx: &C) -> ActorSupervisorwhere
C: Actor,
pub fn into_supervisor<C>(self, cx: &C) -> ActorSupervisorwhere
C: Actor,
Convert this monitor into one that reports detected failures through actor supervision.
Sourcepub async fn guard<F>(&self, fut: F) -> Result<F::Output, MonitorFailure>where
F: Future,
pub async fn guard<F>(&self, fut: F) -> Result<F::Output, MonitorFailure>where
F: Future,
Run fut until it completes or the monitor fails.
Sourcepub async fn recv<M>(
&self,
receiver: &mut PortReceiver<M>,
) -> Result<Result<M, MailboxError>, MonitorFailure>where
M: Message,
pub async fn recv<M>(
&self,
receiver: &mut PortReceiver<M>,
) -> Result<Result<M, MailboxError>, MonitorFailure>where
M: Message,
Receive the next message from receiver or return a monitor failure.
Trait Implementations§
Source§impl Debug for ActorMonitor
impl Debug for ActorMonitor
Source§impl Drop for ActorMonitor
impl Drop for ActorMonitor
Auto Trait Implementations§
impl !RefUnwindSafe for ActorMonitor
impl !UnwindSafe for ActorMonitor
impl Freeze for ActorMonitor
impl Send for ActorMonitor
impl Sync for ActorMonitor
impl Unpin for ActorMonitor
impl UnsafeUnpin for ActorMonitor
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].