Struct openraft::metrics::Wait

source ·
pub struct Wait<NID, N, A>
where NID: NodeId, N: Node, A: AsyncRuntime,
{ 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>
where NID: NodeId, N: Node, A: AsyncRuntime,

source

pub async fn metrics<T>( &self, func: T, msg: impl ToString ) -> Result<RaftMetrics<NID, N>, WaitError>
where T: Fn(&RaftMetrics<NID, N>) -> bool + OptionalSend,

Wait for metrics to satisfy some condition or timeout.

source

pub async fn vote( &self, want: Vote<NID>, msg: impl ToString ) -> Result<RaftMetrics<NID, N>, WaitError>

Wait for vote to become want or timeout.

source

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.

source

pub 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

Wait until applied exactly want_log(inclusive) logs or timeout.

source

pub 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

Wait until applied at least want_log(inclusive) logs or timeout.

source

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.

source

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.

source

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.

source

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.

source

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.

source

pub 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

Wait for membership to become the expected node id set or timeout.

source

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.

source

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.

source

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.

source

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?;
source

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?;

Auto Trait Implementations§

§

impl<NID, N, A> Freeze for Wait<NID, N, A>

§

impl<NID, N, A> !RefUnwindSafe for Wait<NID, N, A>

§

impl<NID, N, A> Send for Wait<NID, N, A>

§

impl<NID, N, A> Sync for Wait<NID, N, A>

§

impl<NID, N, A> Unpin for Wait<NID, N, A>
where A: Unpin,

§

impl<NID, N, A> !UnwindSafe for Wait<NID, N, A>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> OptionalSend for T
where T: Send + ?Sized,

source§

impl<T> OptionalSync for T
where T: Sync + ?Sized,