Skip to main content

Generation

Struct Generation 

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

A process generation keeps admitted sessions alive until their leases drop.

Implementations§

Source§

impl Generation

Source

pub async fn run_until_retired<F, Fut>( &self, interval: Duration, staging_lifetime: Duration, refresh: F, ) -> Retirement
where F: FnMut() -> Fut, Fut: Future<Output = ()>,

Refresh application discovery until this process can retire. This loop owns session wakeups and retirement; the callback reads application selection and may invoke the shared replacement transaction.

With a drain limit, the loop also wakes when the limit passes, and checks it before and after every refresh, so no refresh starts once it has passed. A refresh callback that never completes still delays retirement.

Source

pub fn new(own: u64, selected: u64, staged: bool) -> Self

Initialize from the persisted selection and the process’s startup record.

Source

pub fn with_drain_limit(self, limit: Duration) -> Self

Bound how long a superseded generation waits for its session leases.

Without a limit a held lease keeps a superseded generation alive indefinitely. With one, Self::retire and Self::run_until_retired retire it once the limit has passed since a newer generation was first selected, whatever leases remain.

Source

pub fn selected(&self) -> u64

Return the latest observed selected epoch.

Source

pub fn select(&self, selected: u64) -> Result<()>

Observe a committed selection. Binary rollback still requires a larger epoch.

Source

pub fn admit(self: &Arc<Self>) -> Option<SessionLease>

Admit a session unless retirement closed admission.

Source

pub fn retire_if_idle(&self, staging_lifetime: Duration) -> bool

Retire only an idle superseded generation or expired unselected candidate.

Ignores the drain limit; see Self::retire.

Source

pub fn retire(&self, staging_lifetime: Duration) -> Option<Retirement>

Retire an idle superseded generation or expired unselected candidate, or a superseded generation whose drain limit has passed.

Source

pub fn snapshot(&self) -> Snapshot

Snapshot without waiting for any transport I/O.

Source

pub fn subscribe(&self) -> Receiver<()>

Subscribe before reading state so a concurrent release is not missed.

Notifies when the selected generation advances and when a session lease is released: the transitions that can make retirement possible. Admission and SessionLease::mark_legacy do not notify, so Self::run_until_retired does not refresh once per new session.

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.