Skip to content

Commit

Permalink
use tokio sleep
Browse files Browse the repository at this point in the history
  • Loading branch information
ChuckHend committed Nov 13, 2024
1 parent 4b4de44 commit 9ba37d2
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions conductor/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use sqlx::error::Error;
use sqlx::postgres::PgPoolOptions;
use std::env;
use std::sync::{Arc, Mutex};
use std::{thread, time};
use std::time;
use types::{CRUDevent, Event};

mod metrics_reporter;
Expand Down Expand Up @@ -202,7 +202,7 @@ async fn run(metrics: CustomMetrics) -> Result<(), ConductorError> {
}
None => {
debug!("no messages in queue");
thread::sleep(time::Duration::from_secs(1));
tokio::time::sleep(time::Duration::from_secs(1)).await;
continue;
}
};
Expand Down Expand Up @@ -296,8 +296,7 @@ async fn run(metrics: CustomMetrics) -> Result<(), ConductorError> {
);
let _archived = queue
.archive(&control_plane_events_queue, read_msg.msg_id)
.await
.expect("error archiving message from queue");
.await?;
metrics
.conductor_errors
.add(&opentelemetry::Context::current(), 1, &[]);
Expand Down Expand Up @@ -670,8 +669,7 @@ async fn run(metrics: CustomMetrics) -> Result<(), ConductorError> {
// archive message from queue
let archived = queue
.archive(&control_plane_events_queue, read_msg.msg_id)
.await
.expect("error archiving message from queue");
.await?;

metrics
.conductor_completed
Expand Down Expand Up @@ -786,7 +784,7 @@ async fn main() -> std::io::Result<()> {
}
}
warn!("conductor exited, sleeping for 1 second");
thread::sleep(time::Duration::from_secs(1));
tokio::time::sleep(time::Duration::from_secs(1)).await;
}
}
}));
Expand All @@ -810,7 +808,7 @@ async fn main() -> std::io::Result<()> {
}
}
warn!("status_reporter exited, sleeping for 1 second");
thread::sleep(time::Duration::from_secs(1));
tokio::time::sleep(time::Duration::from_secs(1)).await;
}
}
}));
Expand All @@ -830,7 +828,7 @@ async fn main() -> std::io::Result<()> {
}

warn!("metrics_reporter exited, sleeping for 1 second");
thread::sleep(time::Duration::from_secs(1));
tokio::time::sleep(time::Duration::from_secs(1)).await;
}));
}

Expand Down

0 comments on commit 9ba37d2

Please sign in to comment.