Struct raft::prelude::Config[][src]

pub struct Config {
Show 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: u64, 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: 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

max_committed_size_per_ready: u64

Max size for committed entries in a Ready.

Implementations

Creates a new config.

The minimum number of ticks before an election.

The maximum number of ticks before an election.

Runs validations against the config.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.