Skip to content

Commit

Permalink
atf: use saturating_sub when subtracting elapsed duration
Browse files Browse the repository at this point in the history
It can be larger than the desired duration.
  • Loading branch information
jgraettinger committed Jan 30, 2024
1 parent f3a1964 commit 0ce9177
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions airbyte-to-flow/src/connector_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,9 @@ pub async fn run_airbyte_source_connector(
if let Some(interval_minutes) = run_interval_minutes {
let elapsed = Instant::now().duration_since(start_time);
let total_duration = tokio::time::Duration::from_secs(60 * interval_minutes);
tracing::debug!("atf: sleeping for {:?}", total_duration - elapsed);
tokio::time::sleep(total_duration - elapsed).await;
let remainder = total_duration.saturating_sub(elapsed);
tracing::debug!("atf: sleeping for {remainder:?}");
tokio::time::sleep(remainder).await;
}

let r: Result<(), Error> = Ok(());
Expand Down

0 comments on commit 0ce9177

Please sign in to comment.