[][src]Struct libraft::raft::Config

pub struct Config {
    pub id: u64,
    pub peers: Vec<u64>,
    pub learners: Vec<u64>,
    pub election_tick: u64,
    pub heartbeat_tick: u64,
    pub applied: u64,
    pub max_size_per_msg: u64,
    pub max_inflight_msgs: u64,
    pub check_quorum: bool,
    pub pre_vote: bool,
    pub read_only_option: ReadOnlyOption,
    pub disable_proposal_forwarding: bool,
    pub tag: String,
}

Fields

id: u64

id is the identity of the local raft. ID cannot be 0.

peers: Vec<u64>

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

learners: Vec<u64>

learners contains the IDs of all learner nodes (including 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.

election_tick: u64heartbeat_tick: u64

heartbeat_tick 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_tick 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

max_size_per_msg limits 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.MaxUint64 for unlimited, 0 for at most one entry per message.

max_inflight_msgs: u64

max_inflight_msgs limits 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. Setting MaxInflightMsgs to avoid overflowing that sending buffer. TODO (xiangli): feedback to application to limit the proposal rate?

check_quorum: bool

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

pre_vote: bool

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

read_only_option: ReadOnlyOption

ReadOnlyOption specifies how the read only request is processed.

ReadOnlyOption::Safe guarantees the linearizability of the read only request by communicating with the quorum. It is the default and suggested option.

ReadOnlyOption::LeaseBased ensures linearizability of the read only request by relying on the leader lease. It can be affected by clock drift. If the clock drift is unbounded, leader might keep the lease longer than it should (clock can move backward/pause without any bound). ReadIndex is not safe in that case. CheckQuorum MUST be enabled if ReadOnlyOption is ReadOnlyOption::LeaseBased.

disable_proposal_forwarding: bool

disable_proposal_forwarding set to true means that followers will drop proposals, rather than forwarding them to the leader. One use case for this feature would be in a situation where the Raft leader is used to compute the data of a proposal, for example, adding a timestamp from a hybrid logical clock to data in a monotonically increasing way. Forwarding should be disabled to prevent a follower with an innaccurate hybrid logical clock from assigning the timestamp and then forwarding the data to the leader.

tag: String

tag used for logger.

Trait Implementations

impl Default for Config
[src]

impl Debug for Config
[src]

Auto Trait Implementations

impl Send for Config

impl Sync for Config

Blanket Implementations

impl<T> From for T
[src]

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

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

type Error = !

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

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

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

The type returned in the event of a conversion error.