Struct raft::Progress

source ·
pub struct Progress {
    pub matched: u64,
    pub next_idx: u64,
    pub state: ProgressState,
    pub paused: bool,
    pub pending_snapshot: u64,
    pub pending_request_snapshot: u64,
    pub recent_active: bool,
    pub ins: Inflights,
    pub commit_group_id: u64,
    pub committed_index: u64,
}
Expand description

The progress of catching up from a restart.

Fields§

§matched: u64

How much state is matched.

§next_idx: u64

The next index to apply

§state: ProgressState

When in ProgressStateProbe, leader sends at most one replication message per heartbeat interval. It also probes actual progress of the follower.

When in ProgressStateReplicate, leader optimistically increases next to the latest entry sent after sending replication message. This is an optimized state for fast replicating log entries to the follower.

When in ProgressStateSnapshot, leader should have sent out snapshot before and stop sending any replication message.

§paused: bool

Paused is used in ProgressStateProbe. When Paused is true, raft should pause sending replication message to this peer.

§pending_snapshot: u64

This field is used in ProgressStateSnapshot. If there is a pending snapshot, the pendingSnapshot will be set to the index of the snapshot. If pendingSnapshot is set, the replication process of this Progress will be paused. raft will not resend snapshot until the pending one is reported to be failed.

§pending_request_snapshot: u64

This field is used in request snapshot. If there is a pending request snapshot, this will be set to the request index of the snapshot.

§recent_active: bool

This is true if the progress is recently active. Receiving any messages from the corresponding follower indicates the progress is active. RecentActive can be reset to false after an election timeout.

§ins: Inflights

Inflights is a sliding window for the inflight messages. When inflights is full, no more message should be sent. When a leader sends out a message, the index of the last entry should be added to inflights. The index MUST be added into inflights in order. When a leader receives a reply, the previous inflights should be freed by calling inflights.freeTo.

§commit_group_id: u64

Only logs replicated to different group will be committed if any group is configured.

§committed_index: u64

Committed index in raft_log

Implementations§

source§

impl Progress

source

pub fn new(next_idx: u64, ins_size: usize) -> Self

Creates a new progress with the given settings.

source

pub fn become_probe(&mut self)

Changes the progress to a probe.

source

pub fn become_replicate(&mut self)

Changes the progress to a Replicate.

source

pub fn become_snapshot(&mut self, snapshot_idx: u64)

Changes the progress to a snapshot.

source

pub fn snapshot_failure(&mut self)

Sets the snapshot to failure.

source

pub fn is_snapshot_caught_up(&self) -> bool

Returns true if Match is equal or higher than the pendingSnapshot.

source

pub fn maybe_update(&mut self, n: u64) -> bool

Returns false if the given n index comes from an outdated message. Otherwise it updates the progress and returns true.

source

pub fn update_committed(&mut self, committed_index: u64)

update committed_index.

source

pub fn optimistic_update(&mut self, n: u64)

Optimistically advance the index

source

pub fn maybe_decr_to( &mut self, rejected: u64, match_hint: u64, request_snapshot: u64 ) -> bool

Returns false if the given index comes from an out of order message. Otherwise it decreases the progress next index to min(rejected, last) and returns true.

source

pub fn is_paused(&self) -> bool

Determine whether progress is paused.

source

pub fn resume(&mut self)

Resume progress

source

pub fn pause(&mut self)

Pause progress.

source

pub fn update_state(&mut self, last: u64)

Update inflight msgs and next_idx

Trait Implementations§

source§

impl Clone for Progress

source§

fn clone(&self) -> Progress

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for Progress

source§

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

Formats the value using the given formatter. Read more
source§

impl PartialEq<Progress> for Progress

source§

fn eq(&self, other: &Progress) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Progress

source§

impl StructuralEq for Progress

source§

impl StructuralPartialEq for Progress

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> SendSyncUnwindSafe for Twhere T: Send + Sync + UnwindSafe + ?Sized,