use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub enum DriverKind {
    Memory,
    Redis,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(default)]
pub struct QueueConfig {
    pub name: String,
    pub concurrency: usize,
    pub max_retries: u32,
}

impl Default for QueueConfig {
    fn default() -> Self {
        Self {
            name: "default".into(),
            concurrency: 4,
            max_retries: 3,
        }
    }
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(default)]
pub struct JobsConfig {
    pub driver: DriverKind,
    pub redis_url: String,
    pub queues: Vec<QueueConfig>,
}

impl Default for JobsConfig {
    fn default() -> Self {
        Self {
            driver: DriverKind::Memory,
            redis_url: "redis://127.0.0.1:6379".into(),
            queues: vec![QueueConfig::default()],
        }
    }
}
