pub struct Wait<NID, N, A>{
pub timeout: Duration,
pub rx: Receiver<RaftMetrics<NID, N>>,
/* private fields */
}
Expand description
Wait is a wrapper of RaftMetrics channel that impls several utils to wait for metrics to satisfy some condition.
Fields§
§timeout: Duration
§rx: Receiver<RaftMetrics<NID, N>>
Implementations§
source§impl<NID, N, A> Wait<NID, N, A>
impl<NID, N, A> Wait<NID, N, A>
sourcepub async fn metrics<T>(
&self,
func: T,
msg: impl ToString
) -> Result<RaftMetrics<NID, N>, WaitError>
pub async fn metrics<T>( &self, func: T, msg: impl ToString ) -> Result<RaftMetrics<NID, N>, WaitError>
Wait for metrics to satisfy some condition or timeout.
sourcepub async fn vote(
&self,
want: Vote<NID>,
msg: impl ToString
) -> Result<RaftMetrics<NID, N>, WaitError>
pub async fn vote( &self, want: Vote<NID>, msg: impl ToString ) -> Result<RaftMetrics<NID, N>, WaitError>
Wait for vote
to become want
or timeout.
sourcepub async fn current_leader(
&self,
leader_id: NID,
msg: impl ToString
) -> Result<RaftMetrics<NID, N>, WaitError>
pub async fn current_leader( &self, leader_id: NID, msg: impl ToString ) -> Result<RaftMetrics<NID, N>, WaitError>
Wait for current_leader
to become Some(leader_id)
until timeout.
sourcepub async fn log(
&self,
want_log_index: Option<u64>,
msg: impl ToString
) -> Result<RaftMetrics<NID, N>, WaitError>
👎Deprecated since 0.9.0: use log_index()
and applied_index()
instead
pub async fn log( &self, want_log_index: Option<u64>, msg: impl ToString ) -> Result<RaftMetrics<NID, N>, WaitError>
log_index()
and applied_index()
insteadWait until applied exactly want_log
(inclusive) logs or timeout.
sourcepub async fn log_at_least(
&self,
want_log: Option<u64>,
msg: impl ToString
) -> Result<RaftMetrics<NID, N>, WaitError>
👎Deprecated since 0.9.0: use log_index_at_least()
and applied_index_at_least()
instead
pub async fn log_at_least( &self, want_log: Option<u64>, msg: impl ToString ) -> Result<RaftMetrics<NID, N>, WaitError>
log_index_at_least()
and applied_index_at_least()
insteadWait until applied at least want_log
(inclusive) logs or timeout.
sourcepub async fn log_index(
&self,
index: Option<u64>,
msg: impl ToString
) -> Result<RaftMetrics<NID, N>, WaitError>
pub async fn log_index( &self, index: Option<u64>, msg: impl ToString ) -> Result<RaftMetrics<NID, N>, WaitError>
Block until the last log index becomes exactly index
(inclusive) or timeout.
sourcepub async fn log_index_at_least(
&self,
index: Option<u64>,
msg: impl ToString
) -> Result<RaftMetrics<NID, N>, WaitError>
pub async fn log_index_at_least( &self, index: Option<u64>, msg: impl ToString ) -> Result<RaftMetrics<NID, N>, WaitError>
Block until the last log index becomes at least index
(inclusive) or timeout.
sourcepub async fn applied_index(
&self,
index: Option<u64>,
msg: impl ToString
) -> Result<RaftMetrics<NID, N>, WaitError>
pub async fn applied_index( &self, index: Option<u64>, msg: impl ToString ) -> Result<RaftMetrics<NID, N>, WaitError>
Block until the applied index becomes exactly index
(inclusive) or timeout.
sourcepub async fn applied_index_at_least(
&self,
index: Option<u64>,
msg: impl ToString
) -> Result<RaftMetrics<NID, N>, WaitError>
pub async fn applied_index_at_least( &self, index: Option<u64>, msg: impl ToString ) -> Result<RaftMetrics<NID, N>, WaitError>
Block until the last applied log index become at least index
(inclusive) or timeout.
Note that this also implies last_log_id >= index
.
sourcepub async fn state(
&self,
want_state: ServerState,
msg: impl ToString
) -> Result<RaftMetrics<NID, N>, WaitError>
pub async fn state( &self, want_state: ServerState, msg: impl ToString ) -> Result<RaftMetrics<NID, N>, WaitError>
Wait for state
to become want_state
or timeout.
sourcepub async fn members(
&self,
want_members: BTreeSet<NID>,
msg: impl ToString
) -> Result<RaftMetrics<NID, N>, WaitError>
👎Deprecated since 0.9.0: use voter_ids()
instead
pub async fn members( &self, want_members: BTreeSet<NID>, msg: impl ToString ) -> Result<RaftMetrics<NID, N>, WaitError>
voter_ids()
insteadWait for membership
to become the expected node id set or timeout.
sourcepub async fn voter_ids(
&self,
voter_ids: impl IntoIterator<Item = NID>,
msg: impl ToString
) -> Result<RaftMetrics<NID, N>, WaitError>
pub async fn voter_ids( &self, voter_ids: impl IntoIterator<Item = NID>, msg: impl ToString ) -> Result<RaftMetrics<NID, N>, WaitError>
Block until membership contains exact the expected voter_ids
or timeout.
sourcepub async fn snapshot(
&self,
snapshot_last_log_id: LogId<NID>,
msg: impl ToString
) -> Result<RaftMetrics<NID, N>, WaitError>
pub async fn snapshot( &self, snapshot_last_log_id: LogId<NID>, msg: impl ToString ) -> Result<RaftMetrics<NID, N>, WaitError>
Wait for snapshot
to become snapshot_last_log_id
or timeout.
sourcepub async fn purged(
&self,
want: Option<LogId<NID>>,
msg: impl ToString
) -> Result<RaftMetrics<NID, N>, WaitError>
pub async fn purged( &self, want: Option<LogId<NID>>, msg: impl ToString ) -> Result<RaftMetrics<NID, N>, WaitError>
Wait for purged
to become want
or timeout.
sourcepub async fn ge(
&self,
metric: Metric<NID>,
msg: impl ToString
) -> Result<RaftMetrics<NID, N>, WaitError>
pub async fn ge( &self, metric: Metric<NID>, msg: impl ToString ) -> Result<RaftMetrics<NID, N>, WaitError>
Block until a metric becomes greater than or equal the specified value or timeout.
For example, to await until the term becomes 2 or greater:
my_raft.wait(None).ge(Metric::Term(2), "become term 2").await?;
sourcepub async fn eq(
&self,
metric: Metric<NID>,
msg: impl ToString
) -> Result<RaftMetrics<NID, N>, WaitError>
pub async fn eq( &self, metric: Metric<NID>, msg: impl ToString ) -> Result<RaftMetrics<NID, N>, WaitError>
Block until a metric becomes equal to the specified value or timeout.
For example, to await until the term becomes exact 2:
my_raft.wait(None).eq(Metric::Term(2), "become term 2").await?;