Struct raftstore::store::util::Lease[][src]

pub struct Lease {
    bound: Option<Either<Timespec, Timespec>>,
    max_lease: Duration,
    max_drift: Duration,
    last_update: Timespec,
    remote: Option<RemoteLease>,
}

Lease records an expired time, for examining the current moment is in lease or not. It’s dedicated to the Raft leader lease mechanism, contains either state of

  1. Suspect Timestamp A suspicious leader lease timestamp, which marks the leader may still hold or lose its lease until the clock time goes over this timestamp.
  2. Valid Timestamp A valid leader lease timestamp, which marks the leader holds the lease for now. The lease is valid until the clock time goes over this timestamp.
Time
|---------------------------------->
        ^               ^
       Now           Suspect TS
State:  |    Suspect    |   Suspect

|---------------------------------->
        ^               ^
       Now           Valid TS
State:  |     Valid     |   Expired

Note:

Fields

bound: Option<Either<Timespec, Timespec>>max_lease: Durationmax_drift: Durationlast_update: Timespecremote: Option<RemoteLease>

Implementations

impl Lease[src]

pub fn new(max_lease: Duration) -> Lease[src]

fn next_expired_time(&self, send_ts: Timespec) -> Timespec[src]

The valid leader lease should be lease = max_lease - (commit_ts - send_ts) And the expired timestamp for that leader lease is commit_ts + lease, which is send_ts + max_lease in short.

pub fn renew(&mut self, send_ts: Timespec)[src]

Renew the lease to the bound.

pub fn suspect(&mut self, send_ts: Timespec)[src]

Suspect the lease to the bound.

pub fn inspect(&self, ts: Option<Timespec>) -> LeaseState[src]

Inspect the lease state for the ts or now.

pub fn expire(&mut self)[src]

pub fn expire_remote_lease(&mut self)[src]

pub fn maybe_new_remote_lease(&mut self, term: u64) -> Option<RemoteLease>[src]

Return a new RemoteLease if there is none.

Trait Implementations

impl Debug for Lease[src]

Auto Trait Implementations

impl RefUnwindSafe for Lease

impl Send for Lease

impl Sync for Lease

impl Unpin for Lease

impl UnwindSafe for Lease

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<V, W> ConvertFrom<W> for V where
    W: ConvertTo<V>, 
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pointable for T[src]

type Init = T

The type for initializers.

impl<T> Pointable for T[src]

type Init = T

The type for initializers.

impl<T> Same<T> for T[src]

type Output = T

Should always be Self

impl<T> Sealed<T> for T where
    T: ?Sized
[src]

impl<T> SendSyncUnwindSafe for T where
    T: Send + Sync + UnwindSafe + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 
[src]