fc-queue-runner: use LISTEN/NOTIFY for reactive wakeups
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I3b6f0f5eff05caf7a04a9da7de8b558f6a6a6964
This commit is contained in:
parent
edaf4313e9
commit
49638d5d14
2 changed files with 15 additions and 2 deletions
|
|
@ -68,8 +68,15 @@ async fn main() -> anyhow::Result<()> {
|
|||
|
||||
let worker_pool_for_drain = worker_pool.clone();
|
||||
|
||||
let wakeup = Arc::new(tokio::sync::Notify::new());
|
||||
let listener_handle = fc_common::pg_notify::spawn_listener(
|
||||
db.pool(),
|
||||
&[fc_common::pg_notify::CHANNEL_BUILDS_CHANGED],
|
||||
wakeup.clone(),
|
||||
);
|
||||
|
||||
tokio::select! {
|
||||
result = fc_queue_runner::runner_loop::run(db.pool().clone(), worker_pool, poll_interval) => {
|
||||
result = fc_queue_runner::runner_loop::run(db.pool().clone(), worker_pool, poll_interval, wakeup) => {
|
||||
if let Err(e) = result {
|
||||
tracing::error!("Runner loop failed: {e}");
|
||||
}
|
||||
|
|
@ -83,6 +90,9 @@ async fn main() -> anyhow::Result<()> {
|
|||
}
|
||||
}
|
||||
|
||||
listener_handle.abort();
|
||||
let _ = listener_handle.await;
|
||||
|
||||
tracing::info!("Queue runner shutting down, closing database pool");
|
||||
db.close().await;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue