pub struct WriterLease {
pub database_key: String,
pub holder_id: String,
pub term: u64,
pub generation: u64,
pub acquired_at_ms: u64,
pub expires_at_ms: u64,
}Expand description
One snapshot of who owns the writer lease for a database key.
Fields§
§database_key: String§holder_id: String§term: u64Replication term the holder acquired the lease under (issue #835,
ADR 0030). Tying the lease to the term is what makes a deposed
primary fail closed: once a new primary acquires the lease at a
higher term, the old holder’s term is behind and every term-gated
op it attempts is fenced. Defaults to
DEFAULT_REPLICATION_TERM
when read from a legacy (pre-#835) lease object that did not carry
a term, so older lease files stay readable.
generation: u64§acquired_at_ms: u64§expires_at_ms: u64Implementations§
Source§impl WriterLease
impl WriterLease
pub fn is_expired(&self, now_ms: u64) -> bool
Sourcepub fn fenced_by_term(&self, current_term: u64) -> bool
pub fn fenced_by_term(&self, current_term: u64) -> bool
Is this lease fenced by current_term? A holder whose lease was
stamped under a term behind the cluster’s current term is a
stale writer from a superseded timeline (issue #835) — it must
fail closed rather than keep mutating the new timeline.
Sourcepub fn fencing_token(&self) -> (u64, u64)
pub fn fencing_token(&self) -> (u64, u64)
The monotonic fencing token (term, generation). Both components
advance forward across a legitimate handover (a new primary wins a
higher term and takes a fresh lease generation), so a stale
holder is ordered strictly behind on both axes (ADR 0030).
Trait Implementations§
Source§impl Clone for WriterLease
impl Clone for WriterLease
Source§fn clone(&self) -> WriterLease
fn clone(&self) -> WriterLease
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for WriterLease
impl Debug for WriterLease
impl Eq for WriterLease
Source§impl PartialEq for WriterLease
impl PartialEq for WriterLease
Source§fn eq(&self, other: &WriterLease) -> bool
fn eq(&self, other: &WriterLease) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for WriterLease
Auto Trait Implementations§
impl Freeze for WriterLease
impl RefUnwindSafe for WriterLease
impl Send for WriterLease
impl Sync for WriterLease
impl Unpin for WriterLease
impl UnsafeUnpin for WriterLease
impl UnwindSafe for WriterLease
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request