Skip to main content

Lifecycle

Struct Lifecycle 

Source
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

Source

pub fn observed(observations: Arc<Observations>) -> Self

Attach local events; the consumer owns their export and retention.

Source

pub fn snapshot(&self) -> LifecycleSnapshot

Observe admission without waiting for requests or transport writes.

Source

pub fn begin(self: &Arc<Self>) -> Option<RequestGuard>

Admit an operation unless draining has started.

Source

pub fn start_drain(&self) -> bool

Close admission and wake shutdown observers. Only the first call is true.

Source

pub fn accepting_calls(&self) -> bool

Whether a new operation can still acquire a guard.

Source

pub async fn draining(&self)

Wait until admission has closed, including when it closed before this call.

Source

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.

Source

pub async fn drain(&self)

Close admission and wait for every guard without a timeout.

Source

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.

Trait Implementations§

Source§

impl Default for Lifecycle

Source§

fn default() -> Self

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.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.