pub struct SupervisorState {
pub child_specs: Vec<ChildSpec>,
pub child_failure_state: HashMap<String, ChildFailureState>,
pub restart_log: Vec<RestartLog>,
pub options: SupervisorOptions,
}Expand description
Holds the supervisor’s live state: which children are running, how many times each child has failed, etc.
§Important
The child_specs vector maintains the startup order of children which is critical for
strategies like RestForOne that rely on child ordering.
Fields§
§child_specs: Vec<ChildSpec>The original child specs (each child’s config).
child_failure_state: HashMap<String, ChildFailureState>Tracks how many times each child has failed and the last time it failed.
restart_log: Vec<RestartLog>Rolling log of all restarts in the meltdown window.
options: SupervisorOptionsSupervisor meltdown options.
Implementations§
Source§impl SupervisorState
impl SupervisorState
pub async fn spawn_child( &mut self, child_spec: &ChildSpec, myself: ActorRef<SupervisorMsg>, ) -> Result<(), ActorProcessingErr>
Sourcepub async fn spawn_all_children(
&mut self,
myself: ActorRef<SupervisorMsg>,
) -> Result<(), ActorProcessingErr>
pub async fn spawn_all_children( &mut self, myself: ActorRef<SupervisorMsg>, ) -> Result<(), ActorProcessingErr>
Spawn all children in the order they were defined in SupervisorArguments::child_specs.
Sourcepub async fn perform_one_for_one_spawn(
&mut self,
child_id: &str,
myself: ActorRef<SupervisorMsg>,
) -> Result<(), ActorProcessingErr>
pub async fn perform_one_for_one_spawn( &mut self, child_id: &str, myself: ActorRef<SupervisorMsg>, ) -> Result<(), ActorProcessingErr>
OneForOne: meltdown-check first, then spawn just the failing child.
Sourcepub async fn perform_one_for_all_spawn(
&mut self,
child_id: &str,
myself: ActorRef<SupervisorMsg>,
) -> Result<(), ActorProcessingErr>
pub async fn perform_one_for_all_spawn( &mut self, child_id: &str, myself: ActorRef<SupervisorMsg>, ) -> Result<(), ActorProcessingErr>
OneForAll: meltdown-check first, then stop all children, re-spawn them all.
Sourcepub async fn perform_rest_for_one_spawn(
&mut self,
child_id: &str,
myself: ActorRef<SupervisorMsg>,
) -> Result<(), ActorProcessingErr>
pub async fn perform_rest_for_one_spawn( &mut self, child_id: &str, myself: ActorRef<SupervisorMsg>, ) -> Result<(), ActorProcessingErr>
RestForOne: meltdown-check first, then stop the failing child and all subsequent children, re-spawn them.
Trait Implementations§
Source§impl Clone for SupervisorState
impl Clone for SupervisorState
Source§fn clone(&self) -> SupervisorState
fn clone(&self) -> SupervisorState
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl SupervisorCore for SupervisorState
impl SupervisorCore for SupervisorState
type Message = SupervisorMsg
type Options = SupervisorOptions
type Strategy = SupervisorStrategy
fn child_failure_state(&mut self) -> &mut HashMap<String, ChildFailureState>
fn restart_log(&mut self) -> &mut Vec<RestartLog>
fn options(&self) -> &SupervisorOptions
fn restart_msg( &self, child_spec: &ChildSpec, strategy: SupervisorStrategy, _myself: ActorRef<SupervisorMsg>, ) -> SupervisorMsg
Source§fn prepare_child_failure(
&mut self,
child_spec: &ChildSpec,
) -> Result<(), ActorProcessingErr>
fn prepare_child_failure( &mut self, child_spec: &ChildSpec, ) -> Result<(), ActorProcessingErr>
Resets the child’s
restart_count to 0 if the time since last fail >= child’s restart_counter_reset_after.Source§fn handle_child_exit(
&mut self,
child_spec: &ChildSpec,
abnormal: bool,
) -> Result<bool, ActorProcessingErr>
fn handle_child_exit( &mut self, child_spec: &ChildSpec, abnormal: bool, ) -> Result<bool, ActorProcessingErr>
Source§fn handle_child_restart(
&mut self,
child_spec: &ChildSpec,
abnormal: bool,
myself: ActorRef<Self::Message>,
) -> Result<(), ActorProcessingErr>
fn handle_child_restart( &mut self, child_spec: &ChildSpec, abnormal: bool, myself: ActorRef<Self::Message>, ) -> Result<(), ActorProcessingErr>
Source§fn track_global_restart(
&mut self,
child_id: &str,
) -> Result<(), ActorProcessingErr>
fn track_global_restart( &mut self, child_id: &str, ) -> Result<(), ActorProcessingErr>
Source§fn schedule_restart(
&mut self,
child_spec: &ChildSpec,
strategy: Self::Strategy,
myself: ActorRef<Self::Message>,
) -> Result<(), ActorProcessingErr>
fn schedule_restart( &mut self, child_spec: &ChildSpec, strategy: Self::Strategy, myself: ActorRef<Self::Message>, ) -> Result<(), ActorProcessingErr>
backoff_fn.