pub enum Role {
Unattached {
election_deadline: SimInstant,
},
Voted {
election_deadline: SimInstant,
},
Follower {
leader_id: NodeId,
fetch_deadline: SimInstant,
has_fetched_from_leader: bool,
},
Prospective {
granted: BTreeSet<NodeId>,
rejected: BTreeSet<NodeId>,
election_deadline: SimInstant,
abandoned_leader: Option<NodeId>,
},
Candidate {
granted: BTreeSet<NodeId>,
election_deadline: SimInstant,
},
Leader {
replicas: BTreeMap<NodeId, ReplicaProgress>,
fetched_voters: BTreeSet<NodeId>,
high_watermark: i64,
epoch_start_offset: i64,
},
Resigned,
Observer {
leader_id: Option<NodeId>,
fetch_deadline: SimInstant,
},
}Variants§
Unattached
Knows the epoch, no leader yet. May hold a non-binding pre-vote grant.
Fields
election_deadline: SimInstantVoted
Cast a binding vote this epoch; now waits for a leader.
Fields
election_deadline: SimInstantFollower
Has a leader for the epoch and fetches from it.
Fields
fetch_deadline: SimInstantProspective
KIP-996 pre-vote candidate that collects non-binding grants.
Fields
rejected: BTreeSet<NodeId>The voters that refused the pre-vote. Kafka’s EpochElection
records them so that the round ends as soon as it can no longer
win.
election_deadline: SimInstantabandoned_leader: Option<NodeId>The leader of this epoch that the replica gave up on when it began
the round, if it had one. Kafka’s ProspectiveState keeps the
leaderId of the FollowerState it came from, and a replica that
knows a leader for its epoch grants no binding vote in it.
QuorumState::leader_id is None meanwhile, so that the replica
still attaches to a leader announced at this epoch.
Candidate
Real candidacy: the epoch is bumped and the replica voted for itself.
Leader
Won the election; tracks follower progress for HWM.
Fields
replicas: BTreeMap<NodeId, ReplicaProgress>fetched_voters: BTreeSet<NodeId>Voters that have fetched inside the current check-quorum window.
This is Kafka’s LeaderState.fetchedVoters: it never contains the
leader itself, and it is emptied — and the check-quorum timer
re-armed — the moment it reaches the majority the leader needs
besides its own vote. A leader that reaches the deadline with the
set still short of that count has lost the quorum and resigns.
epoch_start_offset: i64Log end offset at the moment of promotion, that is, where this
leader’s LeaderChange record sits. That record is the first
current-epoch record.
The HWM may only advance past this offset. This enforces Raft Fig.8 leader completeness: a current-epoch entry must be majority-replicated before commit.
Resigned
Stepped down: told the voters to elect, and waits for its own election timer to start a pre-vote round.
A leader reaches this variant when its check-quorum window expires. It
no longer serves Fetch, no longer advances the high watermark, and no
longer claims the leadership in QuorumState, so an isolated old leader
stops answering as leader for its epoch.
Observer
Not in the voter set; only ever fetches.
Implementations§
Trait Implementations§
impl Eq for Role
impl StructuralPartialEq for Role
Auto Trait Implementations§
impl Freeze for Role
impl RefUnwindSafe for Role
impl Send for Role
impl Sync for Role
impl Unpin for Role
impl UnsafeUnpin for Role
impl UnwindSafe for Role
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,
impl<F> FnGhost for F
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);