diff --git a/src/bin/cib.rs b/src/bin/cib.rs index b663b5b8..b13ac171 100644 --- a/src/bin/cib.rs +++ b/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)?; diff --git a/src/config.rs b/src/config.rs index 3b5982f6..241c678a 100644 --- a/src/config.rs +++ b/src/config.rs @@ -54,6 +54,9 @@ pub struct Config { concurrent_adapters: Option, description: Option, + + #[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 { 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 { serde_json::to_string_pretty(self).map_err(ConfigError::to_json) } diff --git a/src/queueproc.rs b/src/queueproc.rs index 981485f2..5c5f3e10 100644 --- a/src/queueproc.rs +++ b/src/queueproc.rs @@ -41,6 +41,7 @@ pub struct QueueProcessorBuilder { run_tx: Option, queue_len_interval: Option, concurrent_adapters: Option, + 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