pub struct ApplicationLifecycle { /* private fields */ }Expand description
Shared process-local readiness and graceful-drain coordinator.
Required component labels are immutable and intentionally absent from the public health payload. Applications update them only after performing their own authenticated dependency checks. This type does not discover services, coordinate replicas, or authorize domain requests.
Implementations§
Source§impl ApplicationLifecycle
impl ApplicationLifecycle
Sourcepub fn with_required_components<I, S>(
components: I,
) -> Result<Self, ApplicationLifecycleError>
pub fn with_required_components<I, S>( components: I, ) -> Result<Self, ApplicationLifecycleError>
Creates a lifecycle with an immutable bounded set of required components.
Sourcepub fn phase(&self) -> ApplicationPhase
pub fn phase(&self) -> ApplicationPhase
Returns the current monotonic phase.
Sourcepub fn mark_ready(&self) -> Result<(), ApplicationLifecycleError>
pub fn mark_ready(&self) -> Result<(), ApplicationLifecycleError>
Marks startup complete without overriding required component states.
Sourcepub fn set_component_ready(
&self,
component: impl Into<String>,
ready: bool,
) -> Result<(), ApplicationLifecycleError>
pub fn set_component_ready( &self, component: impl Into<String>, ready: bool, ) -> Result<(), ApplicationLifecycleError>
Updates one pre-registered dependency readiness bit.
Sourcepub fn begin_draining(&self) -> Result<(), ApplicationLifecycleError>
pub fn begin_draining(&self) -> Result<(), ApplicationLifecycleError>
Begins a monotonic drain and rejects all subsequent application requests.
Sourcepub fn mark_stopped(&self)
pub fn mark_stopped(&self)
Marks the lifecycle stopped. This terminal transition is idempotent.
Sourcepub fn snapshot(&self) -> ReadinessSnapshot
pub fn snapshot(&self) -> ReadinessSnapshot
Returns a secret-minimized readiness snapshot.
Sourcepub fn in_flight_requests(&self) -> usize
pub fn in_flight_requests(&self) -> usize
Returns admitted requests whose handler or HTTP response body is still active. Upgraded connections and detached background work require separate tracking.
Sourcepub async fn wait_for_drain(
&self,
timeout: Duration,
) -> Result<(), ApplicationLifecycleError>
pub async fn wait_for_drain( &self, timeout: Duration, ) -> Result<(), ApplicationLifecycleError>
Waits for admitted handlers and response bodies to finish or be dropped. This does not wait for client acknowledgement or upgraded connections.