pub struct LeasedOwner { /* private fields */ }Expand description
A range owner’s local view of its own ownership lease — the thing that decides whether it may take a durable write right now.
This is the home of owner self-fence behavior. It holds at most one lease (a
lease is per-range, so one LeasedOwner tracks one owned range) plus a
revoked flag the Supervisor can trip. evaluate folds the
lease, the revoke flag, the current Supervisor term, the range’s current
ownership epoch, and the current time into an OwnerWriteMode; everything
else is built on that one decision.
Implementations§
Source§impl LeasedOwner
impl LeasedOwner
Sourcepub fn unleased() -> LeasedOwner
pub fn unleased() -> LeasedOwner
An owner holding no lease — self-fenced until one is granted.
Sourcepub fn with_lease(lease: OwnershipLease) -> LeasedOwner
pub fn with_lease(lease: OwnershipLease) -> LeasedOwner
An owner holding lease.
Sourcepub fn grant(&mut self, lease: OwnershipLease)
pub fn grant(&mut self, lease: OwnershipLease)
Install a freshly-granted (or renewed) lease, clearing any prior revoke. Renewing is how the owner extends its window before the old one expires.
Sourcepub fn revoke(&mut self)
pub fn revoke(&mut self)
Revoke the current lease. The owner self-fences immediately on its next
evaluate, without waiting for the window to close —
this is the Supervisor’s explicit “stop writing now” ahead of a handoff.
Sourcepub fn lease(&self) -> Option<&OwnershipLease>
pub fn lease(&self) -> Option<&OwnershipLease>
The lease currently held, if any. None once revoked-and-dropped or never
granted; note a held-but-invalid lease (expired, stale term/epoch) still
returns Some here — validity is evaluate’s job.
Sourcepub fn evaluate(
&self,
current_term: SupervisorTerm,
current_epoch: OwnershipEpoch,
now_ms: u64,
) -> OwnerWriteMode
pub fn evaluate( &self, current_term: SupervisorTerm, current_epoch: OwnershipEpoch, now_ms: u64, ) -> OwnerWriteMode
Decide the owner’s durable-write authority against the current control
plane. The lease must be present and un-revoked, granted under the current
current_term, carry the range’s current current_epoch, and still be
inside its validity window at now_ms. Any failure self-fences with the
corresponding FenceReason.
Checks run fail-closed in order of authority: an explicit revoke first, then absence of a lease, then Supervisor-term supersession, then ownership epoch supersession, then time expiry. The first cause that holds is the one reported.
Sourcepub fn admit_request(
&self,
request: RangeRequest,
current_term: SupervisorTerm,
current_epoch: OwnershipEpoch,
now_ms: u64,
) -> Result<(), LeaseFenceRejection>
pub fn admit_request( &self, request: RangeRequest, current_term: SupervisorTerm, current_epoch: OwnershipEpoch, now_ms: u64, ) -> Result<(), LeaseFenceRejection>
Admit (or refuse) a request in light of the owner’s current mode — the
encoding of self-fenced read mode. A DurableWrite needs a valid
lease; a StaleRead and ReplicationCatchUp are served regardless,
so a fenced owner keeps answering reads and catching up replicas while it
rejects durable writes.
Trait Implementations§
Source§impl Clone for LeasedOwner
impl Clone for LeasedOwner
Source§fn clone(&self) -> LeasedOwner
fn clone(&self) -> LeasedOwner
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 LeasedOwner
impl Debug for LeasedOwner
Source§impl Default for LeasedOwner
impl Default for LeasedOwner
Source§fn default() -> LeasedOwner
fn default() -> LeasedOwner
impl Eq for LeasedOwner
Source§impl PartialEq for LeasedOwner
impl PartialEq for LeasedOwner
impl StructuralPartialEq for LeasedOwner
Auto Trait Implementations§
impl Freeze for LeasedOwner
impl RefUnwindSafe for LeasedOwner
impl Send for LeasedOwner
impl Sync for LeasedOwner
impl Unpin for LeasedOwner
impl UnsafeUnpin for LeasedOwner
impl UnwindSafe for LeasedOwner
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