pub struct PreVote {
pub term: Term,
pub candidate: NodeId,
pub last_log_index: Index,
pub last_log_term: Term,
}Expand description
A candidate’s pre-vote probe, sent before it commits to a real election.
Pre-voting (Raft thesis §9.6) is a disruption guard. Before a node increments
its term and campaigns for real, it asks its peers whether they would vote
for it at the next term — without bumping anyone’s term. A peer grants only if
it has no active leader and the candidate’s log is up to date (the same
election restriction a real vote applies). The candidate runs a real
RequestVote election only once a quorum of pre-votes says yes.
The point is that a node partitioned away from the cluster never collects a
pre-vote majority, so it never inflates its term. When it rejoins it does not
force the established leader to step down, which is the disruption a plain
election would cause. Unlike RequestVote, a pre-vote changes no persistent
state on either side.
§Examples
use raft_io::PreVote;
// The `term` is the *hypothetical* term the candidate would campaign at —
// one past its current term — not a term it has adopted.
let pv = PreVote { term: 5, candidate: 2, last_log_index: 9, last_log_term: 3 };
assert_eq!(pv.candidate, 2);Fields§
§term: TermThe hypothetical term the candidate would campaign at — one past its current term. It is not a term the candidate has adopted; a recipient neither stores it nor steps down for it.
candidate: NodeIdThe candidate seeking the pre-vote.
last_log_index: IndexIndex of the candidate’s last log entry.
last_log_term: TermTerm of the candidate’s last log entry.