async fn wait_for_completion_of_in_flight_uploads(
    freq: Duration,
    quiet_for: Duration,
    timeout: Duration,
    metric: &IntGauge,
) -> Result<Duration, WaitError> {
    // set our starting time.
    let start_graceful_time = Instant::now();
    let mut current_quiet = start_graceful_time;

    // quit if the most recent quite time exeeds the requested quiet period.
    while current_quiet.elapsed() < quiet_for {
        // * return a timeout error if we have waited past the requested timeout.
        exceeded_timeout(&start_graceful_time, &timeout)?;

        // we are still trying to load files if the passed in metric is greater than 0
        while metric.get() > 0 {
            // * return a timeout error if we have waited past the requested timeout.
            exceeded_timeout(&start_graceful_time, &timeout)?;

            trace!("awaiting in flight requests to complete.");
            delay_for(freq).await;
            current_quiet = Instant::now();
        }
        trace!("awaiting graceperiod.");
        delay_for(freq).await;
    }
    Ok(start_graceful_time.elapsed())
}
// ? Not sure how I can still use start_graceful_time after assigning it to current_quiet.
// ? Is this because of the Copy trait?
//
// @freq: how often to check the metric (sleep between checks)
// @quiet_for: how long the metric must be 0 before we can consider that there are no further uploads to be made
// @timeout: how long is too long to wait.
// @metric: prometheus metric representing in flight uploads
? Not sure how I can still use start_graceful_time after assigning it to current_quiet.
? Not sure how I can still use start_graceful_time after assigning it to current_quiet .
async fn wait_for_completion_of_in_flight_uploads(
    freq: Duration,
    quiet_for: Duration,
    timeout: Duration,
    metric: &IntGauge,
) -> Result<Duration, WaitError> {
    // set our starting time.
    let start_graceful_time = Instant::now();
    let mut current_quiet = start_graceful_time;
    // quit if the most recent quite time exeeds the requested quiet period.
    while current_quiet.elapsed() < quiet_for {
        // * return a timeout error if we have waited past the requested timeout.
        exceeded_timeout(&start_graceful_time, &timeout)?;
        // we are still trying to load files if the passed in metric is greater than 0
        while metric.get() > 0 {
            // * return a timeout error if we have waited past the requested timeout.
            exceeded_timeout(&start_graceful_time, &timeout)?;
            trace!("awaiting in flight requests to complete.");
            delay_for(freq).await;
            current_quiet = Instant::now();
        }
        trace!("awaiting graceperiod.");
        delay_for(freq).await;
    }
    Ok(start_graceful_time.elapsed())
}
async fn wait_for_completion_of_in_flight_uploads ( freq : Duration , quiet_for : Duration , timeout : Duration , metric : & IntGauge , ) -> Result < Duration , WaitError > { // set our starting time. let start_graceful_time = Instant :: now ( ) ; let mut current_quiet = start_graceful_time ; // quit if the most recent quite time exeeds the requested quiet period. while current_quiet . elapsed ( ) < quiet_for { // * return a timeout error if we have waited past the requested timeout. exceeded_timeout ( & start_graceful_time , & timeout ) ? ; // we are still trying to load files if the passed in metric is greater than 0 while metric . get ( ) > 0 { // * return a timeout error if we have waited past the requested timeout. exceeded_timeout ( & start_graceful_time , & timeout ) ? ; trace ! ( " " ) ; delay_for ( freq ) . await ; current_quiet = Instant :: now ( ) ; } trace ! ( " " ) ; delay_for ( freq ) . await ; } Ok ( start_graceful_time . elapsed ( ) ) }
?
?
freq
Duration
quiet_for
Duration
timeout
Duration
metric
&IntGauge
freq
Duration
quiet_for
Duration
timeout
Duration
metric
&IntGauge
freq:
None
quiet_for:
None
timeout:
None
metric:
prometheus metric representing in flight uploads
prometheus metric representing in flight uploads