Expand description
ComponentRegistry: ordered, dependency-aware, type-erased registry
for every Component in the runtime.
§Responsibilities
- Registration:
ComponentRegistry::register_factoryqueues a component kind for initialization. - Dependency resolution: factory metadata lists
depends_onnames; the registry topologically sorts the graph and refuses to proceed if a cycle is present. - Type erasure: components are stored as
Arc<dyn AnyComponent>so the registry can hold heterogeneous instances. Typed access usesComponentRegistry::getto downcast back to a concreteArc<C>. - Lifecycle orchestration:
ComponentRegistry::init_all,ComponentRegistry::start_all,ComponentRegistry::stop_alldrive the four-phase component lifecycle in dependency order. - Health aggregation:
ComponentRegistry::healthfans outAnyComponent::healthcalls concurrently and collects the results into a single map for/healthzresponses.
§Lifecycle ordering
register(...) # queues factory
↓
init_all() # topo order, dep-first
↓
start_all() # topo order
... serve ...
↓
stop_all() # reverse topo orderOn init error, the registry leaves the offending component in a
ComponentState::Failed state and continues to attempt
initialization of any components that do not depend on it. This
maximizes operator visibility: a single broken optional backend
should not prevent the rest of the system from coming up.
Structs§
- Component
Descriptor - Static descriptor of a component kind, used by the registry to plan initialization order without holding the actual factory.
- Component
Registry - The central component registry.
- Typed
AnyComponent - Adapter from a typed
Componentto the type-erasedAnyComponenttrait. Created byTypedFactory::build. - Typed
Factory - Convenience wrapper that adapts a concrete
Componentinto aComponentFactory.
Enums§
- Component
State - Initialization state of a registered component.
- Registry
Error - Errors raised by
ComponentRegistryoperations.
Traits§
- Component
Factory - Type-erased factory for a concrete
Componenttype. The registry holds factories asBox<dyn ComponentFactory>so it can drive heterogeneous types uniformly.