pub struct RuntimeComponentBuilder<'a> { /* private fields */ }Expand description
Builder for one runtime component registration.
Implementations§
Source§impl RuntimeComponentBuilder<'_>
impl RuntimeComponentBuilder<'_>
Sourcepub fn kind(&mut self, kind: RuntimeComponentKind) -> &mut Self
pub fn kind(&mut self, kind: RuntimeComponentKind) -> &mut Self
Sets the component category.
Sourcepub fn depends_on(&mut self, dependency: &'static str) -> &mut Self
pub fn depends_on(&mut self, dependency: &'static str) -> &mut Self
Adds one component dependency.
Sourcepub fn depends_on_all(&mut self, dependencies: &[&'static str]) -> &mut Self
pub fn depends_on_all(&mut self, dependencies: &[&'static str]) -> &mut Self
Adds component dependencies in order.
Sourcepub fn startup<F, Fut>(
&mut self,
phase_name: &'static str,
failure_policy: StartupPhaseFailurePolicy,
phase: F,
) -> &mut Self
pub fn startup<F, Fut>( &mut self, phase_name: &'static str, failure_policy: StartupPhaseFailurePolicy, phase: F, ) -> &mut Self
Registers a component startup phase.
Sourcepub fn task(
&mut self,
task_name: &'static str,
display_name: &'static str,
) -> &mut Self
pub fn task( &mut self, task_name: &'static str, display_name: &'static str, ) -> &mut Self
Registers a component-owned runtime task descriptor.
Sourcepub fn health_with_options<F, Fut>(
&mut self,
check_name: &'static str,
options: HealthCheckOptions,
check: F,
) -> &mut Self
pub fn health_with_options<F, Fut>( &mut self, check_name: &'static str, options: HealthCheckOptions, check: F, ) -> &mut Self
Registers a component health check with explicit options.
Sourcepub fn shutdown<F, Fut>(
&mut self,
phase_name: &'static str,
timeout: Option<Duration>,
phase: F,
) -> &mut Self
pub fn shutdown<F, Fut>( &mut self, phase_name: &'static str, timeout: Option<Duration>, phase: F, ) -> &mut Self
Registers a component shutdown phase.
A component may register multiple shutdown phases; they run in registration order, after the shutdown phases of the component’s dependencies. Registering the same phase name twice for one component is almost always a duplicated registration accident, so it is reported with a warning, but every registered phase still runs.
Sourcepub fn shutdown_once<T, F, Fut>(
&mut self,
phase_name: &'static str,
timeout: Option<Duration>,
value: T,
phase: F,
) -> &mut Self
pub fn shutdown_once<T, F, Fut>( &mut self, phase_name: &'static str, timeout: Option<Duration>, value: T, phase: F, ) -> &mut Self
Registers a shutdown phase that consumes one owned value at most once.
This is the common shape for database handles, background task sets, and other shutdown-only resources. Re-running the registry after the value has already been consumed becomes a no-op success.