pub struct SupervisorState {
    pub child_specs: Vec<ChildSpec>,
    pub running: HashMap<String, ActorCell>,
    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.
Fields§
§child_specs: Vec<ChildSpec>The original child specs (each child’s config).
running: HashMap<String, ActorCell>The currently running children: child_id -> ActorCell.
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
Sourcepub async fn spawn_all_children(
    &mut self,
    supervisor_cell: ActorCell,
) -> Result<(), ActorProcessingErr>
 
pub async fn spawn_all_children( &mut self, supervisor_cell: ActorCell, ) -> Result<(), ActorProcessingErr>
Spawn all children in the order they were defined in SupervisorArguments::child_specs.
Sourcepub fn prepare_child_failure(
    &mut self,
    child_id: &str,
) -> Result<(), ActorProcessingErr>
 
pub fn prepare_child_failure( &mut self, child_id: &str, ) -> Result<(), ActorProcessingErr>
Increments the failure count for a given child.
Resets the child’s restart_count to 0 if the time since last fail >= child’s restart_counter_reset_after.
Sourcepub fn get_child_id_by_cell_id(&self, cell_id: ActorId) -> Option<String>
 
pub fn get_child_id_by_cell_id(&self, cell_id: ActorId) -> Option<String>
Return the child ID for a given ActorCell, if it’s in the running map.
Sourcepub fn handle_child_exit(
    &mut self,
    child_id: &str,
    abnormal: bool,
) -> Result<Option<String>, ActorProcessingErr>
 
pub fn handle_child_exit( &mut self, child_id: &str, abnormal: bool, ) -> Result<Option<String>, ActorProcessingErr>
Called when a child terminates or fails.
- If abnormal == true, we treat it like a panic or error exit.
- We remove the child from running.
- If the child’s Restartpolicy indicates a restart is needed, we do it.
Returns Some(child_id) if the supervisor should re-spawn the child, or None otherwise.
Sourcepub fn schedule_restart(
    &mut self,
    child_id: &String,
    strategy: Strategy,
    myself: ActorRef<SupervisorMsg>,
) -> Result<(), ActorProcessingErr>
 
pub fn schedule_restart( &mut self, child_id: &String, strategy: Strategy, myself: ActorRef<SupervisorMsg>, ) -> Result<(), ActorProcessingErr>
Schedule a future spawn for a child, respecting any child-level backoff_fn.
Sourcepub async fn perform_one_for_one_spawn(
    &mut self,
    child_id: &str,
    supervisor_cell: ActorCell,
) -> Result<(), ActorProcessingErr>
 
pub async fn perform_one_for_one_spawn( &mut self, child_id: &str, supervisor_cell: ActorCell, ) -> 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>,
    supervisor_cell: ActorCell,
) -> Result<(), ActorProcessingErr>
 
pub async fn perform_one_for_all_spawn( &mut self, child_id: &str, myself: ActorRef<SupervisorMsg>, supervisor_cell: ActorCell, ) -> 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>,
    supervisor_cell: ActorCell,
) -> Result<(), ActorProcessingErr>
 
pub async fn perform_rest_for_one_spawn( &mut self, child_id: &str, myself: ActorRef<SupervisorMsg>, supervisor_cell: ActorCell, ) -> Result<(), ActorProcessingErr>
RestForOne: meltdown-check first, then stop the failing child and all subsequent children, re-spawn them.