Struct raft::prelude::Config

source ·
pub struct Config {
Show 16 fields 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: i64, pub max_uncommitted_size: u64, pub max_committed_size_per_ready: u64,
}
Expand description

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: i64

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

§max_committed_size_per_ready: u64

Max size for committed entries in a Ready.

Implementations§

source§

impl Config

source

pub fn new(id: u64) -> Self

Creates a new config.

source

pub fn min_election_tick(&self) -> usize

The minimum number of ticks before an election.

source

pub fn max_election_tick(&self) -> usize

The maximum number of ticks before an election.

source

pub fn validate(&self) -> Result<()>

Runs validations against the config.

Trait Implementations§

source§

impl Clone for Config

source§

fn clone(&self) -> Config

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 Default for Config

source§

fn default() -> Self

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

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,