use once_cell::sync::OnceCell;
#[derive(Debug, Clone, Copy)]
pub struct DownloaderConfig {
pub max_concurrent_downloads: usize,
pub max_retries: u32,
pub initial_delay_ms: u64,
}
impl Default for DownloaderConfig {
fn default() -> Self {
Self {
max_concurrent_downloads: 50,
max_retries: 3,
initial_delay_ms: 20,
}
}
}
static DOWNLOADER_CONFIG: OnceCell<DownloaderConfig> = OnceCell::new();
pub fn init_downloader_config(config: DownloaderConfig) {
DOWNLOADER_CONFIG.set(config).ok();
}
pub(crate) fn get_config() -> DownloaderConfig {
*DOWNLOADER_CONFIG.get_or_init(DownloaderConfig::default)
}