Struct raft::Config[][src]

pub struct Config {
    pub id: u64,
    pub election_tick: usize,
    pub heartbeat_tick: usize,
    pub applied: u64,
    pub max_size_per_msg: u64,
    pub max_inflight_msgs: usize,
    pub check_quorum: bool,
    pub pre_vote: bool,
    pub min_election_tick: usize,
    pub max_election_tick: usize,
    pub read_only_option: ReadOnlyOption,
    pub skip_bcast_commit: bool,
    pub batch_append: bool,
    pub priority: u64,
    pub max_uncommitted_size: u64,
}

Config contains the parameters to start a raft.

Fields

id: u64

The identity of the local raft. It cannot be 0, and must be unique in the group.

election_tick: usize

The number of node.tick invocations that must pass between elections. That is, if a follower does not receive any message from the leader of current term before ElectionTick has elapsed, it will become candidate and start an election. election_tick must be greater than HeartbeatTick. We suggest election_tick = 10 * HeartbeatTick to avoid unnecessary leader switching

heartbeat_tick: usize

HeartbeatTick is the number of node.tick invocations that must pass between heartbeats. That is, a leader sends heartbeat messages to maintain its leadership every heartbeat ticks.

applied: u64

Applied is the last applied index. It should only be set when restarting raft. raft will not return entries to the application smaller or equal to Applied. If Applied is unset when restarting, raft might return previous applied entries. This is a very application dependent configuration.

max_size_per_msg: u64

Limit the max size of each append message. Smaller value lowers the raft recovery cost(initial probing and message lost during normal operation). On the other side, it might affect the throughput during normal replication. Note: math.MaxUusize64 for unlimited, 0 for at most one entry per message.

max_inflight_msgs: usize

Limit the max number of in-flight append messages during optimistic replication phase. The application transportation layer usually has its own sending buffer over TCP/UDP. Set to avoid overflowing that sending buffer. TODO: feedback to application to limit the proposal rate?

check_quorum: bool

Specify if the leader should check quorum activity. Leader steps down when quorum is not active for an electionTimeout.

pre_vote: bool

Enables the Pre-Vote algorithm described in raft thesis section 9.6. This prevents disruption when a node that has been partitioned away rejoins the cluster.

min_election_tick: usize

The range of election timeout. In some cases, we hope some nodes has less possibility to become leader. This configuration ensures that the randomized election_timeout will always be suit in [min_election_tick, max_election_tick). If it is 0, then election_tick will be chosen.

max_election_tick: usize

If it is 0, then 2 * election_tick will be chosen.

read_only_option: ReadOnlyOption

Choose the linearizability mode or the lease mode to read data. If you don’t care about the read consistency and want a higher read performance, you can use the lease mode.

Setting this to LeaseBased requires check_quorum = true.

skip_bcast_commit: bool

Don’t broadcast an empty raft entry to notify follower to commit an entry. This may make follower wait a longer time to apply an entry. This configuration May affect proposal forwarding and follower read.

batch_append: bool

Batches every append msg if any append msg already exists

priority: u64

The election priority of this node.

max_uncommitted_size: u64

Specify maximum of uncommitted entry size. When this limit is reached, all proposals to append new log will be dropped

Implementations

impl Config[src]

pub fn new(id: u64) -> Self[src]

Creates a new config.

pub fn min_election_tick(&self) -> usize[src]

The minimum number of ticks before an election.

pub fn max_election_tick(&self) -> usize[src]

The maximum number of ticks before an election.

pub fn validate(&self) -> Result<()>[src]

Runs validations against the config.

Trait Implementations

impl Clone for Config[src]

impl Default for Config[src]

Auto Trait Implementations

impl RefUnwindSafe for Config

impl Send for Config

impl Sync for Config

impl Unpin for Config

impl UnwindSafe for Config

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<T> From<T> for T[src]

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

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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]