use serde::Deserialize;
use swym_dal::config::DatabaseConfig;

#[derive(Debug, Deserialize)]
pub struct WorkerConfig {
    pub database: DatabaseConfig,

    /// Flush trade/L1 buffers when they reach this size
    #[serde(default = "default_batch_size")]
    pub batch_size: usize,

    /// Flush buffers at least this often (milliseconds)
    #[serde(default = "default_flush_interval_ms")]
    pub flush_interval_ms: u64,

    /// How often to poll the DB for new subscriptions (seconds)
    #[serde(default = "default_poll_interval_secs")]
    pub poll_interval_secs: u64,
}

fn default_batch_size() -> usize {
    1000
}

fn default_flush_interval_ms() -> u64 {
    5000
}

fn default_poll_interval_secs() -> u64 {
    30
}
