Radish alpha
r
Radicle CI broker
Radicle
Git (anonymous pull)
Log in to clone via SSH
feat: allow disabling updates to job COBs in config
✓ CI success Lars Wirzenius committed 9 days ago
commit bf8be65677b361b9293069788ee4fe94d1528e42
parent ecce2a73a573aa7107aef1d6c1807f69b28c2822
1 passed (1 total) View logs
3 files changed +28 -3
modified src/bin/cib.rs
@@ -219,6 +219,7 @@ impl QueuedCmd {
            .triggers(&config.to_triggers())
            .adapters(&adapters)
            .concurrent_adapters(config.concurrent_adapters())
+
            .update_job_cobs(config.update_job_cobs())
            .build()
            .map_err(CibError::process_queue)?;
        let thread = start_thread(processor);
@@ -303,6 +304,7 @@ impl ProcessEventsCmd {
            .triggers(&config.to_triggers())
            .adapters(&adapters)
            .concurrent_adapters(config.concurrent_adapters())
+
            .update_job_cobs(config.update_job_cobs())
            .build()
            .map_err(CibError::process_queue)?;

modified src/config.rs
@@ -54,6 +54,9 @@ pub struct Config {
    concurrent_adapters: Option<usize>,

    description: Option<String>,
+

+
    #[serde(default = "default_update_job_cobs")]
+
    update_job_cobs: bool,
}

fn default_max_run_time() -> Duration {
@@ -64,6 +67,10 @@ fn default_queue_len_interval() -> Duration {
    DEFAULT_QUEUE_LEN_INTERVAL
}

+
fn default_update_job_cobs() -> bool {
+
    true
+
}
+

impl Config {
    pub fn load(filename: &Path) -> Result<Self, ConfigError> {
        let config = std::fs::read(filename).map_err(|e| ConfigError::read_config(filename, e))?;
@@ -140,6 +147,10 @@ impl Config {
        &self.db
    }

+
    pub fn update_job_cobs(&self) -> bool {
+
        self.update_job_cobs
+
    }
+

    pub fn to_json(&self) -> Result<String, ConfigError> {
        serde_json::to_string_pretty(self).map_err(ConfigError::to_json)
    }
modified src/queueproc.rs
@@ -41,6 +41,7 @@ pub struct QueueProcessorBuilder {
    run_tx: Option<NotificationSender>,
    queue_len_interval: Option<Duration>,
    concurrent_adapters: Option<usize>,
+
    update_known_job_cobs: bool,
}

const DEFAULT_QUEUE_LEN_DURATION: Duration = Duration::from_secs(10);
@@ -58,6 +59,14 @@ impl QueueProcessorBuilder {
            .ok_or(QueueError::Missing("concurrent_adapters"))?;
        let (child_pid_tx, child_pid_rx) = channel();

+
        let known_job_cobs = if self.update_known_job_cobs {
+
            eprintln!("XXX update job COBs");
+
            KnownJobCobs::updater().map_err(QueueError::KnownJobCobs)?
+
        } else {
+
            eprintln!("XXX do NOT update job COBs");
+
            KnownJobCobs::NoUpdates
+
        };
+

        Ok(QueueProcessor {
            profile,
            broker,
@@ -75,9 +84,7 @@ impl QueueProcessorBuilder {
            current: CurrentlyPicked::default(),
            child_pid_tx,
            child_pid_rx,
-
            known_job_cobs: Arc::new(Mutex::new(
-
                KnownJobCobs::updater().map_err(QueueError::KnownJobCobs)?,
-
            )),
+
            known_job_cobs: Arc::new(Mutex::new(known_job_cobs)),
        })
    }

@@ -125,6 +132,11 @@ impl QueueProcessorBuilder {
        self.adapters = Some(adapters.clone());
        self
    }
+

+
    pub fn update_job_cobs(mut self, value: bool) -> Self {
+
        self.update_known_job_cobs = value;
+
        self
+
    }
}

// The queue processor gets events from the event queue in