pub mod in_memory;
use crate::error::JobResult;
use crate::job::Job;
use crate::types::{JobExecutionAttempt, JobId, JobStatistics, JobStatus};
use async_trait::async_trait;
#[async_trait]
pub trait JobStorage: Send + Sync {
async fn create_job(&self, job: &Job) -> JobResult<()>;
async fn update_job(&self, job: &Job) -> JobResult<()>;
async fn get_job(&self, job_id: &JobId) -> JobResult<Option<Job>>;
async fn delete_job(&self, job_id: &JobId) -> JobResult<()>;
async fn list_jobs(&self) -> JobResult<Vec<Job>>;
async fn list_jobs_by_status(&self, status: JobStatus) -> JobResult<Vec<Job>>;
async fn get_pending_jobs(&self, before: chrono::DateTime<chrono::Utc>) -> JobResult<Vec<Job>>;
async fn update_job_status(&self, job_id: &JobId, status: JobStatus) -> JobResult<()>;
async fn update_next_run_time(&self, job_id: &JobId, next_run: chrono::DateTime<chrono::Utc>) -> JobResult<()>;
async fn record_execution_attempt(&self, job_id: &JobId, attempt: &JobExecutionAttempt) -> JobResult<()>;
async fn get_execution_history(&self, job_id: &JobId, limit: Option<u32>) -> JobResult<Vec<JobExecutionAttempt>>;
async fn get_statistics(&self) -> JobResult<JobStatistics>;
async fn cleanup_old_attempts(&self, older_than: chrono::DateTime<chrono::Utc>) -> JobResult<u64>;
}
pub use in_memory::InMemoryJobStorage;