pub struct Election {
pub epoch: u64,
/* private fields */
}Expand description
State for an in-progress automatic failover election.
Created when a replica detects its primary has failed. Discarded when the election succeeds (promotion triggered) or times out.
Fields§
§epoch: u64Config epoch this election is contesting.
Implementations§
Source§impl Election
impl Election
Sourcepub fn record_vote(&mut self, from: NodeId, total_primaries: usize) -> bool
pub fn record_vote(&mut self, from: NodeId, total_primaries: usize) -> bool
Records a vote from from. Returns true if quorum is newly reached.
total_primaries is the number of alive primaries (excluding the
failed one) at the time the election started. Quorum is a simple
majority: total_primaries / 2 + 1.
Once quorum is reached this returns true exactly once; subsequent
calls return false so the caller promotes exactly once.
Sourcepub fn is_promoted(&self) -> bool
pub fn is_promoted(&self) -> bool
Returns true if this election has already succeeded.
Auto Trait Implementations§
impl Freeze for Election
impl RefUnwindSafe for Election
impl Send for Election
impl Sync for Election
impl Unpin for Election
impl UnsafeUnpin for Election
impl UnwindSafe for Election
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more