Skip to main content

init_all

Function init_all 

Source
pub fn init_all(stage: InitStage) -> Result<(), ComponentInitError>
Expand description

Initialize all components registered for stage in dependency order.

§Algorithm (Kahn’s topological sort)

  1. Collect every ComponentEntry in .component_entries that matches the requested stage.
  2. Build a directed graph from depends_on edges (A→B: A must run first).
  3. Topological sort with priority as the tiebreaker when multiple components become ready at the same time (lower number = earlier).
  4. Execute each initializer in the computed order.

Cross-stage dependencies (names not found in the current stage) are warned about and skipped — they are assumed to have already run in a prior stage.

Detected cycles are logged as errors; cyclic components are appended in priority order after the acyclic ones (best-effort fallback).