refactor(import): scoped Arc deps, ImportSessionCleanupJob
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::{ImportSessionRepository, PeriodicJob}};
|
||||
|
||||
pub struct ImportSessionCleanupJob {
|
||||
ctx: AppContext,
|
||||
import_session: Arc<dyn ImportSessionRepository>,
|
||||
}
|
||||
|
||||
impl ImportSessionCleanupJob {
|
||||
pub fn new(ctx: AppContext) -> Self {
|
||||
Self { ctx }
|
||||
pub fn new(import_session: Arc<dyn ImportSessionRepository>) -> Self {
|
||||
Self { import_session }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +21,7 @@ impl PeriodicJob for ImportSessionCleanupJob {
|
||||
}
|
||||
|
||||
async fn run(&self) -> Result<(), DomainError> {
|
||||
let n = crate::import::cleanup::execute(&self.ctx).await?;
|
||||
let n = crate::import::cleanup::execute(self.import_session.clone()).await?;
|
||||
tracing::info!("import session cleanup: removed {} expired sessions", n);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user