pub struct InstanceCell { /* private fields */ }Expand description
InstanceCell contains all of the type-erased, shareable state of an instance. Specifically, InstanceCells form a supervision tree, and is used by ActorHandle to access the underlying instance.
InstanceCell is reference counted and cloneable.
Implementations§
Source§impl InstanceCell
impl InstanceCell
Sourcepub fn status(&self) -> &Receiver<ActorStatus>
pub fn status(&self) -> &Receiver<ActorStatus>
The instance’s status observer.
Sourcepub fn supervision_event(&self) -> Option<ActorSupervisionEvent>
pub fn supervision_event(&self) -> Option<ActorSupervisionEvent>
The supervision event stored when this actor failed.
None for actors that stopped cleanly or are still running.
Sourcepub fn send_supervision_event_or_crash(
&self,
child_cx: &impl Actor,
event: ActorSupervisionEvent,
)
pub fn send_supervision_event_or_crash( &self, child_cx: &impl Actor, event: ActorSupervisionEvent, )
Used by this actor’s children to send a supervision event to this actor. When it fails to send, we will crash the process. As part of the crash, all the procs and actors running on this process will be terminated forcefully.
Note that “let it crash” is the default behavior when a supervision event cannot be delivered upstream. It is the upstream’s responsibility to detect and handle crashes.
Sourcepub fn downgrade(&self) -> WeakInstanceCell
pub fn downgrade(&self) -> WeakInstanceCell
Downgrade this InstanceCell to a weak reference.
Sourcepub fn child_count(&self) -> usize
pub fn child_count(&self) -> usize
The number of children this instance has.
Sourcepub fn child_actor_ids(&self) -> Vec<ActorId>
pub fn child_actor_ids(&self) -> Vec<ActorId>
Returns the ActorIds of this instance’s direct children.
Sourcepub fn created_at(&self) -> SystemTime
pub fn created_at(&self) -> SystemTime
When this actor was created.
Sourcepub fn num_processed_messages(&self) -> u64
pub fn num_processed_messages(&self) -> u64
The number of messages processed by this actor.
Sourcepub fn last_message_handler(&self) -> Option<HandlerInfo>
pub fn last_message_handler(&self) -> Option<HandlerInfo>
The last message handler invoked by this actor.
Sourcepub fn total_processing_time_us(&self) -> u64
pub fn total_processing_time_us(&self) -> u64
Total time spent processing messages, in microseconds.
Sourcepub fn parent(&self) -> Option<InstanceCell>
pub fn parent(&self) -> Option<InstanceCell>
Get parent instance cell, if it exists.
Sourcepub fn actor_type_name(&self) -> &str
pub fn actor_type_name(&self) -> &str
The actor’s type name.
Sourcepub fn set_published_attrs(&self, attrs: Attrs)
pub fn set_published_attrs(&self, attrs: Attrs)
Replace the published introspection attrs with a new bag.
Sourcepub fn merge_published_attr<T: AttrValue>(&self, key: Key<T>, value: T)
pub fn merge_published_attr<T: AttrValue>(&self, key: Key<T>, value: T)
Set a single introspection attr, merging into the existing bag (or creating one if none exists).
Sourcepub fn published_attrs(&self) -> Option<Attrs>
pub fn published_attrs(&self) -> Option<Attrs>
Read the published introspection attrs, if any.
Sourcepub fn set_query_child_handler(
&self,
handler: impl Fn(&Reference) -> IntrospectResult + Send + Sync + 'static,
)
pub fn set_query_child_handler( &self, handler: impl Fn(&Reference) -> IntrospectResult + Send + Sync + 'static, )
Register a callback for resolving non-addressable children
via IntrospectMessage::QueryChild.
The callback runs on the actor’s introspect task (a separate
tokio task, not the actor’s message loop), so it must be
Send + Sync and must not access actor-mutable state.
Capture cloned Proc references, not &mut self.
Sourcepub fn query_child(&self, child_ref: &Reference) -> Option<IntrospectResult>
pub fn query_child(&self, child_ref: &Reference) -> Option<IntrospectResult>
Invoke the registered QueryChild handler, if any.
Sourcepub fn store_terminated_snapshot(&self, payload: IntrospectResult)
pub fn store_terminated_snapshot(&self, payload: IntrospectResult)
Store a post-mortem snapshot for this actor in the proc’s
terminated_snapshots map. Called by the introspect task
just before exiting on terminal status.
Eviction policy when the retention cap is exceeded:
- Evict cleanly-stopped actors first (no
failure_info). - When only failed actors remain, evict the most recent
(by
occurred_at), preserving the earliest failures which are closest to the root cause.
Trait Implementations§
Source§impl Clone for InstanceCell
impl Clone for InstanceCell
Source§fn clone(&self) -> InstanceCell
fn clone(&self) -> InstanceCell
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for InstanceCell
impl !RefUnwindSafe for InstanceCell
impl Send for InstanceCell
impl Sync for InstanceCell
impl Unpin for InstanceCell
impl !UnwindSafe for InstanceCell
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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>
Source§impl<A, M> Handler<IndexedErasedUnbound<M>> for A
impl<A, M> Handler<IndexedErasedUnbound<M>> for A
§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].