do_memory_core/learning/
config.rs1pub const DEFAULT_WORKER_COUNT: usize = 4;
7
8pub const DEFAULT_MAX_QUEUE_SIZE: usize = 1000;
10
11pub const DEFAULT_POLL_INTERVAL_MS: u64 = 100;
13
14#[derive(Debug, Clone)]
16pub struct QueueConfig {
17 pub worker_count: usize,
19 pub max_queue_size: usize,
21 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}