pub struct Proposal {
pub node_name: String,
pub dtvlsn: u64,
pub vlsn: u64,
pub priority: u32,
pub term: u64,
pub timestamp_ms: u64,
}Expand description
Represents a candidate’s election proposal.
A proposal captures the state of the candidate at the moment it decides to
run for master. The Ord implementation encodes the election’s preference
rules so that max(proposals) yields the winning candidate.
Fields§
§node_name: StringName of the candidate node.
dtvlsn: u64Durable Transaction VLSN (the MAJOR ranking key, JE Ranking.major).
The highest VLSN known durable on a majority of nodes. 0 means
UNINITIALIZED (pre-DTVLSN), in which case ranking falls back to vlsn
(JE MasterSuggestionGenerator.getRanking: if dtvlsn == UNINITIALIZED return Ranking(vlsn, 0)). Defaults to 0 for back-compat constructors.
vlsn: u64Highest VLSN this node has acknowledged (the MINOR ranking key).
priority: u32Election priority assigned to this node (higher = preferred).
term: u64Election term number.
timestamp_ms: u64Millisecond timestamp of when the proposal was created.
Implementations§
Source§impl Proposal
impl Proposal
Sourcepub fn new(node_name: String, vlsn: u64, priority: u32, term: u64) -> Self
pub fn new(node_name: String, vlsn: u64, priority: u32, term: u64) -> Self
Create a new proposal, automatically timestamped to “now”.
Sourcepub fn with_timestamp(
node_name: String,
vlsn: u64,
priority: u32,
term: u64,
timestamp_ms: u64,
) -> Self
pub fn with_timestamp( node_name: String, vlsn: u64, priority: u32, term: u64, timestamp_ms: u64, ) -> Self
Create a proposal with an explicit timestamp (useful for tests and deserialization).
Sourcepub fn is_better_than(&self, other: &Proposal) -> bool
pub fn is_better_than(&self, other: &Proposal) -> bool
Returns true if this proposal is strictly better than other
according to the election ordering rules.
Sourcepub fn with_dtvlsn(self, dtvlsn: u64) -> Self
pub fn with_dtvlsn(self, dtvlsn: u64) -> Self
Builder: set the DTVLSN (the major ranking key). The election driver
populates this from ReplicatedEnvironment::get_dtvlsn() so the most
durable node, not merely the highest-raw-VLSN node, wins (D2).
Trait Implementations§
impl Eq for Proposal
Source§impl Ord for Proposal
impl Ord for Proposal
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Proposal
impl PartialOrd for Proposal
impl StructuralPartialEq for Proposal
Auto Trait Implementations§
impl Freeze for Proposal
impl RefUnwindSafe for Proposal
impl Send for Proposal
impl Sync for Proposal
impl Unpin for Proposal
impl UnsafeUnpin for Proposal
impl UnwindSafe for Proposal
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more