pub struct OwnershipLease { /* private fields */ }Expand description
Time-bounded write authority for one range owner, issued under a Supervisor term and ownership epoch.
A lease is the owner’s positive permission to take durable writes. It is
per-range (it names its CollectionId + RangeId), bound to the owner it
was issued to, and valid only on the [granted_at_ms, expires_at_ms) window
and only while the Supervisor term and ownership epoch it carries still match
the live cluster. The owner re-validates it on every durable write through
LeasedOwner::evaluate; once any binding no longer holds, the owner
self-fences.
Implementations§
Source§impl OwnershipLease
impl OwnershipLease
Sourcepub fn grant(
supervisor_term: SupervisorTerm,
collection: CollectionId,
range_id: RangeId,
owner: NodeIdentity,
epoch: OwnershipEpoch,
granted_at_ms: u64,
ttl_ms: u64,
) -> OwnershipLease
pub fn grant( supervisor_term: SupervisorTerm, collection: CollectionId, range_id: RangeId, owner: NodeIdentity, epoch: OwnershipEpoch, granted_at_ms: u64, ttl_ms: u64, ) -> OwnershipLease
Grant a lease valid for ttl_ms from granted_at_ms, under
supervisor_term and ownership epoch, for owner’s authority over
(collection, range_id).
pub fn supervisor_term(&self) -> SupervisorTerm
pub fn collection(&self) -> &CollectionId
pub fn range_id(&self) -> RangeId
pub fn owner(&self) -> &NodeIdentity
pub fn epoch(&self) -> OwnershipEpoch
pub fn granted_at_ms(&self) -> u64
pub fn expires_at_ms(&self) -> u64
Sourcepub fn is_expired(&self, now_ms: u64) -> bool
pub fn is_expired(&self, now_ms: u64) -> bool
Has the lease’s validity window closed at now_ms? The window is
half-open: the instant now_ms == expires_at_ms is already expired, so a
lease never grants authority at or past its stated end.
Sourcepub fn remaining_ms(&self, now_ms: u64) -> u64
pub fn remaining_ms(&self, now_ms: u64) -> u64
Milliseconds of authority left at now_ms, saturating to zero once
expired. The owner’s keep-alive uses this to decide when to renew.
Trait Implementations§
Source§impl Clone for OwnershipLease
impl Clone for OwnershipLease
Source§fn clone(&self) -> OwnershipLease
fn clone(&self) -> OwnershipLease
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 OwnershipLease
impl Debug for OwnershipLease
impl Eq for OwnershipLease
Source§impl PartialEq for OwnershipLease
impl PartialEq for OwnershipLease
impl StructuralPartialEq for OwnershipLease
Auto Trait Implementations§
impl Freeze for OwnershipLease
impl RefUnwindSafe for OwnershipLease
impl Send for OwnershipLease
impl Sync for OwnershipLease
impl Unpin for OwnershipLease
impl UnsafeUnpin for OwnershipLease
impl UnwindSafe for OwnershipLease
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