use std::future::Future;
use chrono::{DateTime, Utc};
use uuid::Uuid;
use crate::SyncStats;
use crate::error::AppError;
use crate::job::{CreateJobRequest, HarvestJob, JobStatus};
pub trait JobQueue: Send + Sync + Clone {
fn create_job(
&self,
request: CreateJobRequest,
) -> impl Future<Output = Result<HarvestJob, AppError>> + Send;
fn claim_job(
&self,
worker_id: &str,
) -> impl Future<Output = Result<Option<HarvestJob>, AppError>> + Send;
fn complete_job(
&self,
job_id: Uuid,
stats: SyncStats,
) -> impl Future<Output = Result<(), AppError>> + Send;
fn fail_job(
&self,
job_id: Uuid,
error: &str,
next_retry_at: Option<DateTime<Utc>>,
) -> impl Future<Output = Result<(), AppError>> + Send;
fn cancel_job(
&self,
job_id: Uuid,
stats: Option<SyncStats>,
) -> impl Future<Output = Result<(), AppError>> + Send;
fn get_job(
&self,
job_id: Uuid,
) -> impl Future<Output = Result<Option<HarvestJob>, AppError>> + Send;
fn list_jobs(
&self,
status: Option<JobStatus>,
limit: usize,
) -> impl Future<Output = Result<Vec<HarvestJob>, AppError>> + Send;
fn release_job(&self, job_id: Uuid) -> impl Future<Output = Result<(), AppError>> + Send;
fn release_worker_jobs(
&self,
worker_id: &str,
) -> impl Future<Output = Result<u64, AppError>> + Send;
fn count_by_status(
&self,
status: JobStatus,
) -> impl Future<Output = Result<i64, AppError>> + Send;
}