pub struct ElectionState {
pub node_id: String,
pub role: NodeRole,
pub current_term: u64,
pub voted_for: Option<String>,
pub leader_id: Option<String>,
pub last_heartbeat: DateTime<Utc>,
pub cluster_size: usize,
pub votes_received: HashMap<String, bool>,
}Expand description
Election state for one coordinator instance.
Fields§
§node_id: String§role: NodeRole§current_term: u64§voted_for: Option<String>§leader_id: Option<String>§last_heartbeat: DateTime<Utc>§cluster_size: usize§votes_received: HashMap<String, bool>Implementations§
Source§impl ElectionState
impl ElectionState
pub fn new(node_id: String, cluster_size: usize) -> Self
pub fn become_follower(&mut self, term: u64, leader_id: Option<String>)
pub fn become_candidate(&mut self)
pub fn become_leader(&mut self)
pub fn record_vote(&mut self, voter_id: &str, granted: bool) -> bool
pub fn handle_vote_request(&mut self, req: &VoteRequest) -> VoteResponse
pub fn handle_vote_response(&mut self, voter: &str, resp: VoteResponse) -> bool
Trait Implementations§
Source§impl Clone for ElectionState
impl Clone for ElectionState
Source§fn clone(&self) -> ElectionState
fn clone(&self) -> ElectionState
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ElectionState
impl RefUnwindSafe for ElectionState
impl Send for ElectionState
impl Sync for ElectionState
impl Unpin for ElectionState
impl UnsafeUnpin for ElectionState
impl UnwindSafe for ElectionState
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