use chrono::{DateTime, Utc};
use crate::Job;
#[async_trait::async_trait]
pub trait Storage: Send + Sync {
type Error: std::error::Error + Send + Sync + 'static;
async fn cancel_job(&self, id: i64) -> Result<(), Self::Error>;
async fn complete_job(&self, id: i64) -> Result<(), Self::Error>;
async fn discard_job(&self, id: i64) -> Result<(), Self::Error>;
async fn error_job(
&self,
id: i64,
error_message: &str,
schedule_at: DateTime<Utc>,
) -> Result<(), Self::Error>;
async fn retry_job(&self, id: i64) -> Result<(), Self::Error>;
async fn snooze_job(&self, id: i64, snooze: u64) -> Result<(), Self::Error>;
async fn fetch_jobs(&self) -> Result<Vec<Job>, Self::Error>;
async fn prune_jobs(&self) -> Result<Vec<Job>, Self::Error>;
async fn stage_jobs(&self, concurrency: i32) -> Result<usize, Self::Error>;
async fn fetch_and_execute_jobs(
&self,
queue_name: &str,
limit: i32,
) -> Result<Vec<Job>, Self::Error>;
}