pub async fn wait_for_integration_with_others(
    env: &EnvWrite,
    others: &[&EnvWrite],
    expected_count: usize,
    num_attempts: usize,
    delay: Duration,
    start: Option<std::time::Instant>,
) {
    let mut last_total = 0;
    let this_start = std::time::Instant::now();
    for _ in 0..num_attempts {
        let count = count_integration(env).await;
        let counts = get_counts(others).await;
        let total: usize = counts.0.clone().into_iter().map(|i| i.integrated).sum();
        let num_conductors = counts.0.len() + 1;
        let total_expected = num_conductors * expected_count;
        let progress = if total_expected == 0 {
            0.0
        } else {
            total as f64 / total_expected as f64 * 100.0
        };
        let change = total.checked_sub(last_total).expect("LOST A VALUE");
        last_total = total;
        if count.integrated == expected_count {
            return;
        } else {
            let time_waited = this_start.elapsed().as_secs();
            let total_time_waited = start.map(|s| s.elapsed().as_secs()).unwrap_or(0);
            let ops_per_s = if total_time_waited == 0 {
                0.0
            } else {
                total as f64 / total_time_waited as f64
            };
            tracing::debug!(
                "Count: {}, val: {}, int: {}\nTime waited: {}s (total {}s),\nCounts: {:?}\nTotal: {} out of {} {:.4}% change:{} {:.4}ops/s\n",
                count.integrated,
                count.validation_limbo,
                count.integration_limbo,
                time_waited,
                total_time_waited,
                counts,
                total,
                total_expected,
                progress,
                change,
                ops_per_s,
            );
        }
        tokio::time::sleep(delay).await;
    }
}
/// Same as wait for integration but can print other states at the same time
Same as wait for integration but can print other states at the same time
Same as wait for integration but can print other states at the same time
pub async fn wait_for_integration_with_others(
    env: &EnvWrite,
    others: &[&EnvWrite],
    expected_count: usize,
    num_attempts: usize,
    delay: Duration,
    start: Option<std::time::Instant>,
) {
    let mut last_total = 0;
    let this_start = std::time::Instant::now();
    for _ in 0..num_attempts {
        let count = count_integration(env).await;
        let counts = get_counts(others).await;
        let total: usize = counts.0.clone().into_iter().map(|i| i.integrated).sum();
        let num_conductors = counts.0.len() + 1;
        let total_expected = num_conductors * expected_count;
        let progress = if total_expected == 0 {
            0.0
        } else {
            total as f64 / total_expected as f64 * 100.0
        };
        let change = total.checked_sub(last_total).expect("LOST A VALUE");
        last_total = total;
        if count.integrated == expected_count {
            return;
        } else {
            let time_waited = this_start.elapsed().as_secs();
            let total_time_waited = start.map(|s| s.elapsed().as_secs()).unwrap_or(0);
            let ops_per_s = if total_time_waited == 0 {
                0.0
            } else {
                total as f64 / total_time_waited as f64
            };
            tracing::debug!(
                "Count: {}, val: {}, int: {}\nTime waited: {}s (total {}s),\nCounts: {:?}\nTotal: {} out of {} {:.4}% change:{} {:.4}ops/s\n",
                count.integrated,
                count.validation_limbo,
                count.integration_limbo,
                time_waited,
                total_time_waited,
                counts,
                total,
                total_expected,
                progress,
                change,
                ops_per_s,
            );
        }
        tokio::time::sleep(delay).await;
    }
}
pub async fn wait_for_integration_with_others ( env : & EnvWrite , others : & [ & EnvWrite ] , expected_count : usize , num_attempts : usize , delay : Duration , start : Option < std :: time :: Instant > , ) { let mut last_total = 0 ; let this_start = std :: time :: Instant :: now ( ) ; for _ in 0 .. num_attempts { let count = count_integration ( env ) . await ; let counts = get_counts ( others ) . await ; let total : usize = counts . 0 . clone ( ) . into_iter ( ) . map ( | i | i . integrated ) . sum ( ) ; let num_conductors = counts . 0 . len ( ) + 1 ; let total_expected = num_conductors * expected_count ; let progress = if total_expected == 0 { 0.0 } else { total as f64 / total_expected as f64 * 100.0 } ; let change = total . checked_sub ( last_total ) . expect ( " " ) ; last_total = total ; if count . integrated == expected_count { return ; } else { let time_waited = this_start . elapsed ( ) . as_secs ( ) ; let total_time_waited = start . map ( | s | s . elapsed ( ) . as_secs ( ) ) . unwrap_or ( 0 ) ; let ops_per_s = if total_time_waited == 0 { 0.0 } else { total as f64 / total_time_waited as f64 } ; tracing :: debug ! ( " \n \n \n \n " count integrated count validation_limbo count integration_limbo time_waited total_time_waited counts total total_expected progress change ops_per_s ) ; } tokio :: time :: sleep ( delay ) . await ; } }
Same as wait for integration but can print other states at the same time
Same as wait for integration but can print other states at the same time
env
&EnvWrite
others
&[&EnvWrite]
expected_count
usize
num_attempts
usize
delay
Duration
start
Option<std::time::Instant>
env
&EnvWrite
others
&[&EnvWrite]
expected_count
usize
num_attempts
usize
delay
Duration
start
Option<std::time::Instant>