use crate::error::Result;
use async_trait::async_trait;
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
pub mod memory;
#[cfg(feature = "redis")]
pub mod redis;
#[cfg(feature = "postgres")]
pub mod postgres;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct JobRequest {
pub id: String,
pub name: String,
pub payload: serde_json::Value,
pub created_at: DateTime<Utc>,
pub attempts: u32,
pub max_attempts: u32,
pub last_error: Option<String>,
pub run_at: Option<DateTime<Utc>>,
}
#[async_trait]
pub trait JobBackend: Send + Sync {
async fn push(&self, job: JobRequest) -> Result<()>;
async fn pop(&self) -> Result<Option<JobRequest>>;
async fn complete(&self, job_id: &str) -> Result<()>;
async fn fail(&self, job_id: &str, error: &str) -> Result<()>;
}