mirror of
https://seed.radicle.dev/rad:zwTxygwuz5LDGBq255RA2CbNGrz8.git
synced 2026-10-18 19:30:29 +08:00
feat: allow disabling updates to job COBs in config
This commit is contained in:
@@ -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)?;
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
+15
-3
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user