Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): introduce status_kind in the Context #133

Merged
merged 7 commits into from
Jul 17, 2024
4 changes: 4 additions & 0 deletions elfo-core/src/actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,10 @@ impl Actor {
self.control.write().restart_policy = policy;
}

pub(crate) fn status_kind(&self) -> ActorStatusKind {
nerodono marked this conversation as resolved.
Show resolved Hide resolved
self.control.read().status.kind()
}

// Note that this method should be called inside a right scope.
pub(crate) fn set_status(&self, status: ActorStatus) {
let mut control = self.control.write();
Expand Down
9 changes: 9 additions & 0 deletions elfo-core/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use crate::{
routers::Singleton,
scope,
source::{SourceHandle, Sources, UnattachedSource},
ActorStatusKind,
};

use self::stats::Stats;
Expand Down Expand Up @@ -105,6 +106,14 @@ impl<C, K> Context<C, K> {
ward!(self.actor.as_ref().and_then(|o| o.as_actor())).set_status(status);
}

/// Gets the actor's status kind.
nerodono marked this conversation as resolved.
Show resolved Hide resolved
pub fn status_kind(&self) -> Option<ActorStatusKind> {
nerodono marked this conversation as resolved.
Show resolved Hide resolved
self.actor
.as_ref()
.and_then(|o| o.as_actor())
.map(|a| a.status_kind())
}

/// Overrides the group's default mailbox capacity, which set in the config.
///
/// Note: after restart the actor will be created from scratch, so this
Expand Down