pub struct Supervisor { /* private fields */ }Expand description
A supervisor that manages child actors.
Implementations§
Source§impl Supervisor
impl Supervisor
Sourcepub fn new(strategy: SupervisionStrategy) -> Self
pub fn new(strategy: SupervisionStrategy) -> Self
Create a new supervisor with the given strategy.
Sourcepub fn with_parent(strategy: SupervisionStrategy, parent: ActorId) -> Self
pub fn with_parent(strategy: SupervisionStrategy, parent: ActorId) -> Self
Create a new supervisor with a parent.
Sourcepub fn set_escalation_action(&mut self, action: EscalationAction)
pub fn set_escalation_action(&mut self, action: EscalationAction)
Set the escalation action.
Sourcepub fn start_child(&mut self, spec: ChildSpec) -> Result<ActorId>
pub fn start_child(&mut self, spec: ChildSpec) -> Result<ActorId>
Start a new child actor.
Sourcepub fn stop_child(&mut self, name: &str) -> Result<()>
pub fn stop_child(&mut self, name: &str) -> Result<()>
Stop a child actor gracefully.
Sourcepub fn terminate_child(&mut self, name: &str, reason: ExitReason) -> Result<()>
pub fn terminate_child(&mut self, name: &str, reason: ExitReason) -> Result<()>
Terminate a child actor with a specific reason.
Sourcepub fn which_children(&self) -> Vec<&SupervisedChild>
pub fn which_children(&self) -> Vec<&SupervisedChild>
Get a list of all children.
Sourcepub fn count_children(&self) -> SupervisorStats
pub fn count_children(&self) -> SupervisorStats
Get statistics about the supervisor.
Sourcepub async fn handle_child_exit(
&mut self,
name: &str,
reason: ExitReason,
) -> Result<()>
pub async fn handle_child_exit( &mut self, name: &str, reason: ExitReason, ) -> Result<()>
Handle a child exit event.
Sourcepub fn remove_child(&mut self, name: &str) -> Result<SupervisedChild>
pub fn remove_child(&mut self, name: &str) -> Result<SupervisedChild>
Remove a child from supervision.
Sourcepub fn get_child(&self, name: &str) -> Option<&SupervisedChild>
pub fn get_child(&self, name: &str) -> Option<&SupervisedChild>
Get a child by name.
Sourcepub fn get_child_mut(&mut self, name: &str) -> Option<&mut SupervisedChild>
pub fn get_child_mut(&mut self, name: &str) -> Option<&mut SupervisedChild>
Get a child by name mutably.
Sourcepub fn child_count(&self) -> usize
pub fn child_count(&self) -> usize
Get the number of children.
Sourcepub fn mark_child_running(&mut self, name: &str) -> Result<()>
pub fn mark_child_running(&mut self, name: &str) -> Result<()>
Mark a restarting child as running.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Supervisor
impl RefUnwindSafe for Supervisor
impl Send for Supervisor
impl Sync for Supervisor
impl Unpin for Supervisor
impl UnsafeUnpin for Supervisor
impl UnwindSafe for Supervisor
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
Mutably borrows from an owned value. Read more