Skip to main content

RuntimeComponentRegistry

Struct RuntimeComponentRegistry 

Source
pub struct RuntimeComponentRegistry { /* private fields */ }
Expand description

Registry for runtime component metadata and lifecycle hooks.

Implementations§

Source§

impl RuntimeComponentRegistry

Source

pub fn new() -> Self

Creates an empty component registry.

Source

pub fn configured<F>(configure: F) -> Self
where F: FnOnce(&mut Self),

Creates a registry and applies one product or subsystem registration function.

Source

pub fn configure<F>(&mut self, configure: F) -> &mut Self
where F: FnOnce(&mut Self),

Applies a product or subsystem registration function.

Source

pub fn register_bundle<B>(&mut self, bundle: B) -> &mut Self

Registers one product-owned component bundle.

Source

pub fn component_health_with_options<F, Fut>( &mut self, component_name: &'static str, kind: RuntimeComponentKind, check_name: &'static str, options: HealthCheckOptions, check: F, ) -> &mut Self
where F: Fn() -> Fut + Send + Sync + 'static, Fut: Future<Output = HealthComponentReport> + Send + 'static,

Registers a component health check with explicit options.

Source

pub fn component_startup<F, Fut>( &mut self, component_name: &'static str, kind: RuntimeComponentKind, phase_name: &'static str, failure_policy: StartupPhaseFailurePolicy, phase: F, ) -> &mut Self
where F: FnMut() -> Fut + Send + 'static, Fut: Future<Output = Result<(), String>> + Send + 'static,

Registers a component startup phase.

Source

pub fn component_task( &mut self, component_name: &'static str, kind: RuntimeComponentKind, task_name: &'static str, display_name: &'static str, ) -> &mut Self

Registers a component-owned runtime task descriptor.

Source

pub fn component_shutdown<F, Fut>( &mut self, component_name: &'static str, kind: RuntimeComponentKind, phase_name: &'static str, timeout: Option<Duration>, phase: F, ) -> &mut Self
where F: FnMut() -> Fut + Send + 'static, Fut: Future<Output = Result<(), String>> + Send + 'static,

Registers a component shutdown phase.

Source

pub fn component_shutdown_once<T, F, Fut>( &mut self, component_name: &'static str, kind: RuntimeComponentKind, phase_name: &'static str, timeout: Option<Duration>, value: T, phase: F, ) -> &mut Self
where T: Send + 'static, F: FnOnce(T) -> Fut + Send + 'static, Fut: Future<Output = Result<(), String>> + Send + 'static,

Registers a component shutdown phase that consumes one owned value at most once.

Source

pub fn component(&mut self, name: &'static str) -> RuntimeComponentBuilder<'_>

Returns a builder for name, creating the component when needed.

Source

pub fn descriptors(&self) -> &[RuntimeComponentDescriptor]

Returns registered component descriptors in registration order.

Source

pub fn descriptor(&self, name: &str) -> Option<&RuntimeComponentDescriptor>

Returns one descriptor by component name.

Source

pub const fn health_registry(&self) -> &HealthCheckRegistry

Returns the underlying health registry.

Source

pub const fn health_registry_mut(&mut self) -> &mut HealthCheckRegistry

Returns the underlying health registry mutably.

Source

pub async fn run_health( &mut self, scope: HealthCheckScope, ) -> SystemHealthReport

Runs health checks registered for scope.

Source

pub async fn startup(&mut self) -> StartupReport

Runs registered startup phases.

Source

pub fn validate(&self) -> Result<(), RuntimeComponentGraphError>

Validates that the component dependency graph is resolvable.

Source

pub async fn shutdown(&mut self) -> ShutdownReport

Runs registered shutdown phases in component dependency order.

A component’s dependencies run before that component when both sides have shutdown phases. Multiple phases registered by one component run in registration order. Dependencies without shutdown phases are kept as descriptor metadata and do not block execution. Cycles are reported as warnings and the registry still makes best-effort progress without executing a phase more than once.

Source

pub fn len(&self) -> usize

Returns how many components are registered.

Source

pub fn is_empty(&self) -> bool

Returns whether no components are registered.

Trait Implementations§

Source§

impl Default for RuntimeComponentRegistry

Source§

fn default() -> RuntimeComponentRegistry

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more