refactor(integrations): IngestWatchEventDeps, scoped Arc deps, WatchEventCleanupJob
This commit is contained in:
@@ -1,17 +1,16 @@
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use domain::{errors::DomainError, ports::PeriodicJob};
|
||||
|
||||
use crate::context::AppContext;
|
||||
use domain::{errors::DomainError, ports::{PeriodicJob, WatchEventRepository}};
|
||||
|
||||
pub struct WatchEventCleanupJob {
|
||||
ctx: AppContext,
|
||||
watch_event: Arc<dyn WatchEventRepository>,
|
||||
}
|
||||
|
||||
impl WatchEventCleanupJob {
|
||||
pub fn new(ctx: AppContext) -> Self {
|
||||
Self { ctx }
|
||||
pub fn new(watch_event: Arc<dyn WatchEventRepository>) -> Self {
|
||||
Self { watch_event }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +21,7 @@ impl PeriodicJob for WatchEventCleanupJob {
|
||||
}
|
||||
|
||||
async fn run(&self) -> Result<(), DomainError> {
|
||||
let n = crate::integrations::cleanup::execute(&self.ctx).await?;
|
||||
let n = crate::integrations::cleanup::execute(self.watch_event.clone()).await?;
|
||||
if n > 0 {
|
||||
tracing::info!("watch event cleanup: removed {n} old entries");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user