Struct raft::Raft [] [src]

pub struct Raft<T: Storage> {
    pub term: u64,
    pub vote: u64,
    pub id: u64,
    pub read_states: Vec<ReadState>,
    pub raft_log: RaftLog<T>,
    pub max_inflight: usize,
    pub max_msg_size: u64,
    pub state: StateRole,
    pub is_learner: bool,
    pub votes: FlatMap<u64, bool>,
    pub msgs: Vec<Message>,
    pub leader_id: u64,
    pub lead_transferee: Option<u64>,
    pub pending_conf_index: u64,
    pub read_only: ReadOnly,
    pub election_elapsed: usize,
    pub check_quorum: bool,
    pub before_step_state: Option<Box<FnMut(&Message) -> bool>>,
    // some fields omitted
}

Fields

the log

the leader id

lead_transferee is id of the leader transfer target when its value is not None. Follow the procedure defined in raft thesis 3.10.

Only one conf change may be pending (in the log, but not yet applied) at a time. This is enforced via pending_conf_index, which is set to a value >= the log index of the latest pending configuration change (if any). Config changes are only allowed to be proposed if the leader's applied index is greater than this value.

number of ticks since it reached last electionTimeout when it is leader or candidate. number of ticks since it reached last electionTimeout or received a valid message from current leader when it is a follower.

Will be called when step** is about to be called. return false will skip step**.

Methods

impl<T: Storage> Raft<T>
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

Returns true to indicate that there will probably be some readiness need to be handled.

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

pass_election_timeout returns true iff election_elapsed is greater than or equal to the randomized election timeout in [election_timeout, 2 * election_timeout - 1].

[src]

[src]

[src]

Trait Implementations

impl<T: Default + Storage> Default for Raft<T>
[src]

[src]

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