From ecce2a73a573aa7107aef1d6c1807f69b28c2822 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Mon, 11 May 2026 14:30:34 +0300 Subject: [PATCH] feat: add a variant to KnownJobCobs that makes no updates --- src/adapter.rs | 2 +- src/bin/cibtoolcmd/cob.rs | 2 +- src/broker.rs | 2 +- src/cob.rs | 11 ++++++++++- src/queueproc.rs | 2 +- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/adapter.rs b/src/adapter.rs index 582e0213..cd5f2664 100644 --- a/src/adapter.rs +++ b/src/adapter.rs @@ -535,7 +535,7 @@ mod test { #[allow(clippy::unwrap_used)] fn known() -> Arc> { - Arc::new(Mutex::new(KnownJobCobs::new().unwrap())) + Arc::new(Mutex::new(KnownJobCobs::updater().unwrap())) } #[allow(clippy::unwrap_used)] diff --git a/src/bin/cibtoolcmd/cob.rs b/src/bin/cibtoolcmd/cob.rs index 3fa33d56..03b28d5d 100644 --- a/src/bin/cibtoolcmd/cob.rs +++ b/src/bin/cibtoolcmd/cob.rs @@ -29,7 +29,7 @@ impl Leaf for CobCmd { let url = Url::parse("https://liw.fi").unwrap(); let run_id = RunId::default(); let known = Arc::new(Mutex::new( - KnownJobCobs::new().map_err(CibToolError::KnownJobCobs)?, + KnownJobCobs::updater().map_err(CibToolError::KnownJobCobs)?, )); for i in 0..self.n { println!("{i}"); diff --git a/src/broker.rs b/src/broker.rs index de3a9e40..da9accbe 100644 --- a/src/broker.rs +++ b/src/broker.rs @@ -223,7 +223,7 @@ mod test { #[allow(clippy::unwrap_used)] fn known() -> Arc> { - Arc::new(Mutex::new(KnownJobCobs::new().unwrap())) + Arc::new(Mutex::new(KnownJobCobs::updater().unwrap())) } #[test] diff --git a/src/cob.rs b/src/cob.rs index 5b3e7094..bd36cb3a 100644 --- a/src/cob.rs +++ b/src/cob.rs @@ -29,19 +29,27 @@ use crate::{ergo::Oid, logger, msg::RunId}; /// Lookup cache for job COBs. /// /// This assumes job COBs are not removed from the node. +#[allow(clippy::large_enum_variant)] pub enum KnownJobCobs { + NoUpdates, Updater(JobUpdater), } impl KnownJobCobs { + /// Cre3ate q new [`KnownJobCobs`] that does NOT update job COBs. + pub fn no_updater() -> Self { + Self::NoUpdates + } + /// Create a new [`KnownJobCobs`] that updates job COBs. - pub fn new() -> Result { + pub fn updater() -> Result { Ok(Self::Updater(JobUpdater::new()?)) } /// Look up job COB for a specific commit. pub fn create_job(&mut self, repo_id: RepoId, oid: Oid) -> Option { match self { + Self::NoUpdates => None, Self::Updater(x) => x.create_job(repo_id, oid), } } @@ -58,6 +66,7 @@ impl KnownJobCobs { announce: bool, ) { match self { + Self::NoUpdates => (), Self::Updater(x) => x.create_run(repo_id, oid, run_id, url, announce), } } diff --git a/src/queueproc.rs b/src/queueproc.rs index 1c0ec910..981485f2 100644 --- a/src/queueproc.rs +++ b/src/queueproc.rs @@ -76,7 +76,7 @@ impl QueueProcessorBuilder { child_pid_tx, child_pid_rx, known_job_cobs: Arc::new(Mutex::new( - KnownJobCobs::new().map_err(QueueError::KnownJobCobs)?, + KnownJobCobs::updater().map_err(QueueError::KnownJobCobs)?, )), }) }