feat: configurable job expiration
defaults to 30 days
This commit is contained in:
parent
3123c8c1e0
commit
c6d4f713ac
4 changed files with 5 additions and 6 deletions
|
@ -79,6 +79,9 @@ pub struct SecurityConfig {
|
||||||
|
|
||||||
#[serde_inline_default(20)]
|
#[serde_inline_default(20)]
|
||||||
pub thread_crawl_depth: u32,
|
pub thread_crawl_depth: u32,
|
||||||
|
|
||||||
|
#[serde_inline_default(30)]
|
||||||
|
pub job_expiration_days: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -42,10 +42,6 @@ impl Model {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn expired(&self) -> bool {
|
|
||||||
chrono::Utc::now() - self.published > chrono::Duration::days(7)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn repeat(self) -> ActiveModel {
|
pub fn repeat(self) -> ActiveModel {
|
||||||
ActiveModel {
|
ActiveModel {
|
||||||
internal: sea_orm::ActiveValue::NotSet,
|
internal: sea_orm::ActiveValue::NotSet,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use apb::{target::Addressed, Activity, Base, Object};
|
use apb::{target::Addressed, Activity, Base, Object};
|
||||||
use sea_orm::{sea_query::Expr, ActiveValue::{NotSet, Set}, ColumnTrait, Condition, DatabaseTransaction, EntityTrait, QueryFilter, QuerySelect, SelectColumns, TransactionTrait};
|
use sea_orm::{sea_query::Expr, ActiveValue::{NotSet, Set}, ColumnTrait, Condition, DatabaseTransaction, EntityTrait, QueryFilter, QuerySelect, SelectColumns};
|
||||||
use crate::{ext::{AnyQuery, LoggableError}, model, traits::{fetch::Pull, Addresser, Fetcher, Normalizer}};
|
use crate::{ext::{AnyQuery, LoggableError}, model, traits::{fetch::Pull, Addresser, Fetcher, Normalizer}};
|
||||||
|
|
||||||
#[derive(Debug, thiserror::Error)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
|
|
|
@ -99,7 +99,7 @@ impl JobDispatcher for Context {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if job.expired() {
|
if chrono::Utc::now() > job.published + chrono::Duration::days(self.cfg().security.job_expiration_days as i64) {
|
||||||
tracing::info!("dropping expired job {job:?}");
|
tracing::info!("dropping expired job {job:?}");
|
||||||
restart!(now);
|
restart!(now);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue