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

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

    /// How often to poll for new data to fetch. Default: 1 hour.
    #[serde(default = "default_poll_interval_secs")]
    pub poll_interval_secs: u64,

    /// Number of trades to batch-insert per DB round-trip.
    #[serde(default = "default_batch_size")]
    pub batch_size: usize,

    /// Max number of instrument ingestions to run concurrently.
    #[serde(default = "default_max_concurrent")]
    pub max_concurrent: usize,
}

fn default_poll_interval_secs() -> u64 {
    3600
}

fn default_batch_size() -> usize {
    5000
}

fn default_max_concurrent() -> usize {
    2
}
