pub struct Wait<NID, N>where
NID: NodeId,
N: Node,{
pub timeout: Duration,
pub rx: Receiver<RaftMetrics<NID, N>>,
}
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> Wait<NID, N>where
NID: NodeId,
N: Node,
impl<NID, N> Wait<NID, N>where NID: NodeId, N: Node,
sourcepub async fn metrics<T>(
&self,
func: T,
msg: impl ToString
) -> Result<RaftMetrics<NID, N>, WaitError>where
T: Fn(&RaftMetrics<NID, N>) -> bool + Send,
pub async fn metrics<T>( &self, func: T, msg: impl ToString ) -> Result<RaftMetrics<NID, N>, WaitError>where T: Fn(&RaftMetrics<NID, N>) -> bool + Send,
Wait for metrics to satisfy some condition 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>
pub async fn log( &self, want_log_index: Option<u64>, msg: impl ToString ) -> Result<RaftMetrics<NID, N>, WaitError>
Wait 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>
pub async fn log_at_least( &self, want_log: Option<u64>, msg: impl ToString ) -> Result<RaftMetrics<NID, N>, WaitError>
Wait until applied at least want_log
(inclusive) logs or timeout.
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.