Struct raft::Config[][src]

pub struct Config {
    pub id: u64,
    pub peers: Vec<u64>,
    pub learners: Vec<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 tag: String,
}

Config contains the parameters to start a raft.

Fields

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

The IDs of all nodes (including self) in the raft cluster. It should only be set when starting a new raft cluster. Restarting raft from previous configuration will panic if peers is set. peer is private and only used for testing right now.

The IDs of all learner nodes (maybe include self if the local node is a learner) in the raft cluster. learners only receives entries from the leader node. It does not vote or promote itself.

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

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 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.

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.

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?

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

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.

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.

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

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.

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.

A human-friendly tag used for logging.

Methods

impl Config
[src]

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

impl Default for Config
[src]

Returns the "default value" for a type. Read more

Auto Trait Implementations

impl Send for Config

impl Sync for Config