pub struct GenerationFence { /* private fields */ }Expand description
Binds requests to a host generation. The epoch advances every time the host the lifecycle is
bound to changes (first bind, replacement, exit). A Ticket issued under an older epoch can
never complete: its reply is Stale, so a late reply from a previous host cannot answer a
request made to the next one.
Transports that multiplex requests over one connection use it directly: issue when a request
is written, admit_reply (or admit_reply_from when the reply carries the epoch it was read
under) when its reply arrives.
Implementations§
Source§impl GenerationFence
impl GenerationFence
pub fn new() -> Self
Sourcepub fn advance(&self) -> u64
pub fn advance(&self) -> u64
A different host generation was bound (or the host left): every outstanding Ticket is
now stale. Returns the new epoch.
Sourcepub fn issue(&self, bound_epoch: u64) -> Result<Ticket, Stale>
pub fn issue(&self, bound_epoch: u64) -> Result<Ticket, Stale>
Issue a request under bound_epoch, the epoch the caller’s connection was bound to.
Refused when that is no longer the current epoch.
Sourcepub fn admit_reply(&self, ticket: &Ticket) -> Result<(), Stale>
pub fn admit_reply(&self, ticket: &Ticket) -> Result<(), Stale>
A reply arrived for ticket. Admitted only while the epoch it was issued under is still
the current one.
Sourcepub fn admit_reply_from(
&self,
ticket: &Ticket,
reply_epoch: u64,
) -> Result<(), Stale>
pub fn admit_reply_from( &self, ticket: &Ticket, reply_epoch: u64, ) -> Result<(), Stale>
admit_reply for a reply that itself names the epoch of the
connection it was read from: it must equal the ticket’s epoch as well.