fc-queue-runner: use LISTEN/NOTIFY for reactive wakeups

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I3b6f0f5eff05caf7a04a9da7de8b558f6a6a6964
This commit is contained in:
raf 2026-02-16 21:04:45 +03:00
commit 49638d5d14
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
2 changed files with 15 additions and 2 deletions

View file

@ -5,6 +5,7 @@ use fc_common::{
repo,
};
use sqlx::PgPool;
use tokio::sync::Notify;
use crate::worker::WorkerPool;
@ -12,6 +13,7 @@ pub async fn run(
pool: PgPool,
worker_pool: Arc<WorkerPool>,
poll_interval: Duration,
wakeup: Arc<Notify>,
) -> anyhow::Result<()> {
// Reset orphaned builds from previous crashes (older than 5 minutes)
match repo::builds::reset_orphaned(&pool, 300).await {
@ -185,6 +187,7 @@ pub async fn run(
tracing::error!("Failed to fetch pending builds: {e}");
},
}
tokio::time::sleep(poll_interval).await;
// Wake on NOTIFY or fall back to regular poll interval
let _ = tokio::time::timeout(poll_interval, wakeup.notified()).await;
}
}