Radish alpha
r
Radicle CI broker
Radicle
Git (anonymous pull)
Log in to clone via SSH
feat: add a variant to KnownJobCobs that makes no updates
Lars Wirzenius committed 9 days ago
commit ecce2a73a573aa7107aef1d6c1807f69b28c2822
parent fd7d8a91af7ef5abb760f3a6cd677da985ad30b2
5 files changed +14 -5
modified src/adapter.rs
@@ -535,7 +535,7 @@ mod test {

    #[allow(clippy::unwrap_used)]
    fn known() -> Arc<Mutex<KnownJobCobs>> {
-
        Arc::new(Mutex::new(KnownJobCobs::new().unwrap()))
+
        Arc::new(Mutex::new(KnownJobCobs::updater().unwrap()))
    }

    #[allow(clippy::unwrap_used)]
modified 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}");
modified src/broker.rs
@@ -223,7 +223,7 @@ mod test {

    #[allow(clippy::unwrap_used)]
    fn known() -> Arc<Mutex<KnownJobCobs>> {
-
        Arc::new(Mutex::new(KnownJobCobs::new().unwrap()))
+
        Arc::new(Mutex::new(KnownJobCobs::updater().unwrap()))
    }

    #[test]
modified 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<Self, JobError> {
+
    pub fn updater() -> Result<Self, JobError> {
        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<JobId> {
        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),
        }
    }
modified 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)?,
            )),
        })
    }