Skip to main content

Timing

Struct Timing 

pub struct Timing {
    pub heartbeat_ms: u64,
    pub election_ms: u64,
}
Expand description

Failure detection, in milliseconds of each member’s monotonic clock.

An idle primary sends a heartbeat every heartbeat_ms. A backup that hears nothing from its primary for election_ms, plus a jitter drawn again for every election from 0..election_ms, starts a view change, so the loss of a primary is noticed within one to two election timeouts.

Fields§

§heartbeat_ms: u64§election_ms: u64

Implementations§

§

impl Timing

pub fn validate(&self) -> Result<(), &'static str>

A heartbeat of at least 1 ms and an election timeout of at least four heartbeats, so a backup can miss a few before it suspects the primary.

pub fn promise_ms(&self) -> u64

How long a backup promises, after each ping from its primary, not to take part in a view change: half the election timeout, so an election that times out normally never breaks a promise.

pub fn lease_ms(&self) -> u64

How long after it sent a ping that a quorum answered the primary may serve reads from its own state. The promise as the slowest allowed backup clock measures it, as the fastest allowed primary clock measures it, less a millisecond at each end for clock granularity: (P - 1)(1 - ρ)/(1 + ρ) - 1 with ρ = MAX_CLOCK_DRIFT_PPM.

pub fn step_down_ms(&self) -> u64

How long a primary that hears from no quorum keeps its role: four election timeouts, and at least 200 ms. A backup that is merely slow (a stalled flush, a starting process) answers late; one that lost this primary has elected another long before.

Trait Implementations§

§

impl Clone for Timing

§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for Timing

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
§

impl Default for Timing

§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Forget for Timing

§

impl Freeze for Timing

§

impl Move for Timing

§

impl RefUnwindSafe for Timing

§

impl Send for Timing

§

impl Sync for Timing

§

impl Unpin for Timing

§

impl UnsafeUnpin for Timing

§

impl UnwindSafe for Timing

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.