Skip to main content

do_memory_core/learning/
config.rs

1//! # Queue Configuration
2//!
3//! Configuration constants and settings for the pattern extraction queue.
4
5/// Default number of worker tasks
6pub const DEFAULT_WORKER_COUNT: usize = 4;
7
8/// Default maximum queue size (for backpressure)
9pub const DEFAULT_MAX_QUEUE_SIZE: usize = 1000;
10
11/// Default worker poll interval when queue is empty
12pub const DEFAULT_POLL_INTERVAL_MS: u64 = 100;
13
14/// Configuration for pattern extraction queue
15#[derive(Debug, Clone)]
16pub struct QueueConfig {
17    /// Number of worker tasks to spawn
18    pub worker_count: usize,
19    /// Maximum queue size (0 = unlimited)
20    pub max_queue_size: usize,
21    /// Polling interval when queue is empty (milliseconds)
22    pub poll_interval_ms: u64,
23}
24
25impl Default for QueueConfig {
26    fn default() -> Self {
27        Self {
28            worker_count: DEFAULT_WORKER_COUNT,
29            max_queue_size: DEFAULT_MAX_QUEUE_SIZE,
30            poll_interval_ms: DEFAULT_POLL_INTERVAL_MS,
31        }
32    }
33}
34
35#[cfg(test)]
36mod tests {
37    use super::*;
38
39    #[test]
40    fn test_default_config() {
41        let config = QueueConfig::default();
42        assert_eq!(config.worker_count, DEFAULT_WORKER_COUNT);
43        assert_eq!(config.max_queue_size, DEFAULT_MAX_QUEUE_SIZE);
44        assert_eq!(config.poll_interval_ms, DEFAULT_POLL_INTERVAL_MS);
45    }
46
47    #[test]
48    fn test_custom_config() {
49        let config = QueueConfig {
50            worker_count: 8,
51            max_queue_size: 500,
52            poll_interval_ms: 50,
53        };
54        assert_eq!(config.worker_count, 8);
55        assert_eq!(config.max_queue_size, 500);
56        assert_eq!(config.poll_interval_ms, 50);
57    }
58}