Skip to main content

argyph_embed/
config.rs

1use std::path::PathBuf;
2use std::time::Duration;
3
4use crate::Provider;
5
6#[derive(Clone)]
7pub struct EmbedConfig {
8    pub batch_size: usize,
9    pub max_retries: u32,
10    pub base_delay: Duration,
11    pub concurrency: usize,
12    pub timeout: Duration,
13    pub base_url: Option<String>,
14    pub cache_dir: Option<PathBuf>,
15}
16
17impl EmbedConfig {
18    pub fn for_provider(provider: &Provider) -> Self {
19        Self {
20            concurrency: provider.default_concurrency(),
21            ..Self::default()
22        }
23    }
24}
25
26impl Default for EmbedConfig {
27    fn default() -> Self {
28        Self {
29            batch_size: 100,
30            max_retries: 3,
31            base_delay: Duration::from_secs(1),
32            concurrency: 8,
33            timeout: Duration::from_secs(30),
34            base_url: None,
35            cache_dir: None,
36        }
37    }
38}
39
40#[cfg(test)]
41mod tests {
42    use super::*;
43
44    #[test]
45    fn default_config_values() {
46        let config = EmbedConfig::default();
47        assert_eq!(config.batch_size, 100);
48        assert_eq!(config.max_retries, 3);
49        assert_eq!(config.base_delay, Duration::from_secs(1));
50        assert_eq!(config.concurrency, 8);
51        assert_eq!(config.timeout, Duration::from_secs(30));
52        assert!(config.base_url.is_none());
53        assert!(config.cache_dir.is_none());
54    }
55}