1
0
Fork 0
forked from alemi/upub

fix: delete duplicated jobs

This commit is contained in:
əlemi 2024-06-07 23:16:39 +02:00
parent 746ba4bbee
commit 87d0d7b6d2
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -1,6 +1,6 @@
use sea_orm::{ColumnTrait, EntityTrait, Order, QueryFilter, QueryOrder};
use upub::{model, Context};
use upub::{model, traits::process::ProcessorError, Context};
#[derive(Debug, thiserror::Error)]
pub enum JobError {
@ -124,7 +124,10 @@ impl JobDispatcher for Context {
model::job::JobType::Delivery => crate::delivery::process(_ctx.clone(), &job).await,
};
if let Err(e) = res {
match res {
Ok(()) => tracing::debug!("job {} completed", job.activity),
Err(JobError::ProcessorError(ProcessorError::AlreadyProcessed)) => tracing::info!("dropping job already processed: {}", job.activity),
Err(e) => {
tracing::error!("failed processing job '{}': {e}", job.activity);
let active = job.clone().repeat();
let mut count = 0;
@ -141,6 +144,8 @@ impl JobDispatcher for Context {
tokio::time::sleep(std::time::Duration::from_secs(poll_interval)).await;
}
}
}
});
while pool.len() >= concurrency {