pub struct LeaderId<NID>where
NID: NodeId,{
pub term: u64,
pub node_id: NID,
}
Expand description
LeaderId is identifier of a leader
.
In raft spec that in a term there is at most one leader, thus a term
is enough to
differentiate leaders. That is why raft uses (term, index)
to uniquely identify a log
entry.
Under this dirty simplification, a Leader
is actually identified by (term, voted_for:Option<node_id>)
.
By introducing LeaderId {term, node_id}
, things become easier to understand.
Fields§
§term: u64
§node_id: NID
Implementations§
Trait Implementations§
source§impl<NID> Ord for LeaderId<NID>where
NID: NodeId + Ord,
impl<NID> Ord for LeaderId<NID>where NID: NodeId + Ord,
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl<NID> PartialEq<LeaderId<NID>> for LeaderId<NID>where
NID: NodeId + PartialEq,
impl<NID> PartialEq<LeaderId<NID>> for LeaderId<NID>where NID: NodeId + PartialEq,
source§impl<NID> PartialOrd<LeaderId<NID>> for LeaderId<NID>where
NID: NodeId + PartialOrd,
impl<NID> PartialOrd<LeaderId<NID>> for LeaderId<NID>where NID: NodeId + PartialOrd,
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl<NID> Copy for LeaderId<NID>where NID: NodeId + Copy,
impl<NID> Eq for LeaderId<NID>where NID: NodeId + Eq,
impl<NID> StructuralEq for LeaderId<NID>where NID: NodeId,
impl<NID> StructuralPartialEq for LeaderId<NID>where NID: NodeId,
Auto Trait Implementations§
impl<NID> RefUnwindSafe for LeaderId<NID>where NID: RefUnwindSafe,
impl<NID> Send for LeaderId<NID>
impl<NID> Sync for LeaderId<NID>
impl<NID> Unpin for LeaderId<NID>where NID: Unpin,
impl<NID> UnwindSafe for LeaderId<NID>where NID: UnwindSafe,
Blanket Implementations§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.