Skip to main content

run_update_groups

Function run_update_groups 

Source
pub async fn run_update_groups<T, K, C, FetchFut, RunFut>(
    items: &[T],
    group_of: impl Fn(&T) -> K,
    concurrency: NonZeroUsize,
    fetch_group_context: impl FnMut() -> FetchFut,
    run: impl Fn(&T, Arc<C>) -> RunFut,
) -> Result<Vec<(usize, Error)>>
where K: PartialEq, C: Send + Sync + 'static, FetchFut: Future<Output = Result<C>>, RunFut: Future<Output = Result<()>> + Send + 'static,
Expand description

Runs run over items, grouped by contiguous runs of equal group_of, with at most concurrency items in flight. Each group starts after the previous one has fully finished, and gets a fresh fetch_group_context() result.

Each item runs as its own spawned task so CPU-bound work spreads across runtime workers; items start in input order and dropping the returned future aborts the in-flight tasks. A task that panics is reported as a failure of its item, like an Err. Returns per-item failures (global index, error) in input order. A fetch_group_context error aborts the pass.