pub trait ElectionTransport {
// Required methods
fn members(&self) -> Vec<Member>;
fn request_vote(&mut self, peer_id: &str, req: &VoteRequest) -> VoteDecision;
fn elapsed(&self) -> Duration;
fn bump_term(&mut self, new_term: u64);
fn promote(&mut self, new_term: u64);
}Expand description
Cluster operations the candidate drives, injected so the state machine stays pure and deterministically testable. Production backs these onto the membership view, the per-peer vote RPC, the durable term store, and the FAILOVER handover; tests back them onto a scripted fake.
Required Methods§
Sourcefn members(&self) -> Vec<Member>
fn members(&self) -> Vec<Member>
The candidate’s current view of cluster membership. The denominator for the majority is the voting members of this set.
Sourcefn request_vote(&mut self, peer_id: &str, req: &VoteRequest) -> VoteDecision
fn request_vote(&mut self, peer_id: &str, req: &VoteRequest) -> VoteDecision
Ask one peer for its vote. The candidate never asks itself (it always
self-grants). Implementors route this to the peer’s Voter.
Sourcefn elapsed(&self) -> Duration
fn elapsed(&self) -> Duration
Time elapsed since the election began, so the coordinator enforces the randomized timeout without owning a clock.
Sourcefn bump_term(&mut self, new_term: u64)
fn bump_term(&mut self, new_term: u64)
Durably advance this node’s current term to new_term. Called once,
only when a real election begins (never for a dry-run). Persisted
alongside the node’s other durable replication state.
Sourcefn promote(&mut self, new_term: u64)
fn promote(&mut self, new_term: u64)
Promote the candidate to primary under new_term, reusing the
FAILOVER handover machinery (super::failover). Called only after
a majority is collected in the real election.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".