pub struct Group<K, T, E, S = RandomState> { /* private fields */ }
Expand description
Group represents a class of work and creates a space in which units of work can be executed with duplicate suppression.
Implementations§
Source§impl<K, T, E, S> Group<K, T, E, S>
impl<K, T, E, S> Group<K, T, E, S>
Sourcepub async fn work<Q, F>(&self, key: &Q, fut: F) -> Result<T, Option<E>>
pub async fn work<Q, F>(&self, key: &Q, fut: F) -> Result<T, Option<E>>
Execute and return the value for a given function, making sure that only one operation is in-flight at a given moment.
- If a duplicate call comes in, that caller will wait until the original call completes and return the same value.
- If the leader returns an error, owner call returns error,
others will return
Err(None)
.
Sourcepub async fn work_no_retry<Q, F>(
&self,
key: &Q,
fut: F,
) -> Result<T, GroupWorkError<E>>
pub async fn work_no_retry<Q, F>( &self, key: &Q, fut: F, ) -> Result<T, GroupWorkError<E>>
Execute and return the value for a given function, making sure that only one operation is in-flight at a given moment.
- If a duplicate call comes in, that caller will wait until the original call completes and return the same value.
- If the leader returns an error, owner call returns error,
others will return
Err(GroupWorkError::LeaderFailed)
. - If the leader drops, the call will return
Err(GroupWorkError::LeaderDropped)
.
Trait Implementations§
Auto Trait Implementations§
impl<K, T, E, S = RandomState> !Freeze for Group<K, T, E, S>
impl<K, T, E, S = RandomState> !RefUnwindSafe for Group<K, T, E, S>
impl<K, T, E, S> Send for Group<K, T, E, S>
impl<K, T, E, S> Sync for Group<K, T, E, S>
impl<K, T, E, S> Unpin for Group<K, T, E, S>
impl<K, T, E, S> UnwindSafe for Group<K, T, E, S>where
K: UnwindSafe,
S: UnwindSafe,
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
Mutably borrows from an owned value. Read more