async fn parallel_enqueue<T>(v: T) -> Result<Vec<DmlMeta>, ShardError>
where
    T: Iterator<Item = (Arc<Sequencer>, DmlOperation)> + Send,
{
    let mut successes = vec![];
    let mut errs = vec![];

    v.map(|(sequencer, op)| async move {
        tokio::spawn(async move { sequencer.enqueue(op).await })
            .await
            .expect("shard enqueue panic")
    })
    // Use FuturesUnordered so the futures can run in parallel
    .collect::<FuturesUnordered<_>>()
    .collect::<Vec<_>>()
    .await
    // Sort the result into successes/failures upon completion
    .into_iter()
    .for_each(|v| match v {
        Ok(meta) => successes.push(meta),
        Err(e) => errs.push(e),
    });

    match errs.len() {
        0 => Ok(successes),
        _n => Err(ShardError::WriteBufferErrors {
            successes: successes.len(),
            errs,
        }),
    }
}
/// Enumerates all items in the iterator, maps each to a future that dispatches
/// the [`DmlOperation`] to its paired [`Sequencer`], executes all the futures
/// in parallel and gathers any errors.
///
/// Returns a list of the sequences that were written.
Enumerates all items in the iterator, maps each to a future that dispatches
the [`DmlOperation`] to its paired [`Sequencer`], executes all the futures
in parallel and gathers any errors.

Returns a list of the sequences that were written.
Enumerates all items in the iterator maps each to a future that dispatches the [ ` DmlOperation ` ] to its paired [ ` Sequencer ` ] executes all the futures in parallel and gathers any errors . Returns a list of the sequences that were written .
async fn parallel_enqueue<T>(v: T) -> Result<Vec<DmlMeta>, ShardError>
where
    T: Iterator<Item = (Arc<Sequencer>, DmlOperation)> + Send,
{
    let mut successes = vec![];
    let mut errs = vec![];
    v.map(|(sequencer, op)| async move {
        tokio::spawn(async move { sequencer.enqueue(op).await })
            .await
            .expect("shard enqueue panic")
    })
    // Use FuturesUnordered so the futures can run in parallel
    .collect::<FuturesUnordered<_>>()
    .collect::<Vec<_>>()
    .await
    // Sort the result into successes/failures upon completion
    .into_iter()
    .for_each(|v| match v {
        Ok(meta) => successes.push(meta),
        Err(e) => errs.push(e),
    });
    match errs.len() {
        0 => Ok(successes),
        _n => Err(ShardError::WriteBufferErrors {
            successes: successes.len(),
            errs,
        }),
    }
}
async fn parallel_enqueue < T > ( v : T ) -> Result < Vec < DmlMeta > , ShardError > where T : Iterator < Item = ( Arc < Sequencer > , DmlOperation ) > + Send , { let mut successes = vec ! [ ] ; let mut errs = vec ! [ ] ; v . map ( | ( sequencer , op ) | async move { tokio :: spawn ( async move { sequencer . enqueue ( op ) . await } ) . await . expect ( " " ) } ) // Use FuturesUnordered so the futures can run in parallel . collect :: < FuturesUnordered < _ > > ( ) . collect :: < Vec < _ > > ( ) . await // Sort the result into successes/failures upon completion . into_iter ( ) . for_each ( | v | match v { Ok ( meta ) => successes . push ( meta ) , Err ( e ) => errs . push ( e ) , } ) ; match errs . len ( ) { 0 => Ok ( successes ) , _n => Err ( ShardError :: WriteBufferErrors { successes : successes . len ( ) , errs , } ) , } }
Enumerates all items in the iterator, maps each to a future that dispatches
the [`DmlOperation`] to its paired [`Sequencer`], executes all the futures
in parallel and gathers any errors.
Enumerates all items in the iterator maps each to a future that dispatches the [ ` DmlOperation ` ] to its paired [ ` Sequencer ` ] executes all the futures in parallel and gathers any errors .
v
T
v
T