pub struct Lifecycle { /* private fields */ }Expand description
A one-way request admission gate shared by all sessions of a daemon.
Call begin for each operation, including operations arriving
on existing connections. Keep the returned guard until its reply has been
flushed. Closing a listener alone does not close persistent sessions.
Implementations§
Source§impl Lifecycle
impl Lifecycle
Sourcepub fn observed(observations: Arc<Observations>) -> Self
pub fn observed(observations: Arc<Observations>) -> Self
Attach local events; the consumer owns their export and retention.
Sourcepub fn snapshot(&self) -> LifecycleSnapshot
pub fn snapshot(&self) -> LifecycleSnapshot
Observe admission without waiting for requests or transport writes.
Sourcepub fn begin(self: &Arc<Self>) -> Option<RequestGuard>
pub fn begin(self: &Arc<Self>) -> Option<RequestGuard>
Admit an operation unless draining has started.
Sourcepub fn start_drain(&self) -> bool
pub fn start_drain(&self) -> bool
Close admission and wake shutdown observers. Only the first call is true.
Sourcepub fn accepting_calls(&self) -> bool
pub fn accepting_calls(&self) -> bool
Whether a new operation can still acquire a guard.
Sourcepub async fn draining(&self)
pub async fn draining(&self)
Wait until admission has closed, including when it closed before this call.
Sourcepub async fn unless_draining<T>(
&self,
operation: impl Future<Output = T>,
) -> Option<T>
pub async fn unless_draining<T>( &self, operation: impl Future<Output = T>, ) -> Option<T>
Run operation unless admission closes first. None means draining
started, for example while a persistent connection waited for its next
request; the caller then stops reading from it.
Sourcepub async fn drain_until(&self, deadline: Instant) -> DrainOutcome
pub async fn drain_until(&self, deadline: Instant) -> DrainOutcome
Close admission and wait for all guards, under a single deadline.
A timeout leaves admission closed and the operations running. The caller decides whether they can be cancelled or must be allowed to finish.