mirror of
https://seed.radicle.dev/rad:zwTxygwuz5LDGBq255RA2CbNGrz8.git
synced 2026-10-18 19:30:29 +08:00
feat: add a variant to KnownJobCobs that makes no updates
This commit is contained in:
+1
-1
@@ -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)]
|
||||
|
||||
@@ -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}");
|
||||
|
||||
+1
-1
@@ -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]
|
||||
|
||||
+10
-1
@@ -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),
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -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)?,
|
||||
)),
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user