quantrs2_tytan/realtime_quantum_integration/
config.rs

1//! Configuration types for Real-time Quantum Computing Integration
2//!
3//! This module provides configuration structs.
4
5use serde::{Deserialize, Serialize};
6use std::time::Duration;
7
8use super::types::{AlertChannel, AllocationStrategy, MetricType};
9
10/// Real-time system configuration
11#[derive(Debug, Clone, Serialize, Deserialize)]
12pub struct RealtimeConfig {
13    /// Monitoring interval
14    pub monitoring_interval: Duration,
15    /// Maximum queue size
16    pub max_queue_size: usize,
17    /// Resource allocation strategy
18    pub allocation_strategy: AllocationStrategy,
19    /// Fault detection sensitivity
20    pub fault_detection_sensitivity: f64,
21    /// Performance analytics settings
22    pub analytics_config: AnalyticsConfig,
23    /// Auto-recovery enabled
24    pub auto_recovery_enabled: bool,
25    /// Alert thresholds
26    pub alert_thresholds: AlertThresholds,
27    /// Data retention period
28    pub data_retention_period: Duration,
29}
30
31impl Default for RealtimeConfig {
32    fn default() -> Self {
33        Self {
34            monitoring_interval: Duration::from_millis(100),
35            max_queue_size: 1000,
36            allocation_strategy: AllocationStrategy::LoadBalanced,
37            fault_detection_sensitivity: 0.95,
38            analytics_config: AnalyticsConfig::default(),
39            auto_recovery_enabled: true,
40            alert_thresholds: AlertThresholds::default(),
41            data_retention_period: Duration::from_secs(24 * 3600), // 24 hours
42        }
43    }
44}
45
46/// Analytics configuration
47#[derive(Debug, Clone, Serialize, Deserialize)]
48pub struct AnalyticsConfig {
49    /// Enable real-time metrics collection
50    pub real_time_metrics: bool,
51    /// Enable predictive analytics
52    pub predictive_analytics: bool,
53    /// Metrics aggregation interval
54    pub aggregation_interval: Duration,
55    /// Historical data analysis depth
56    pub analysis_depth: Duration,
57    /// Performance prediction horizon
58    pub prediction_horizon: Duration,
59}
60
61impl Default for AnalyticsConfig {
62    fn default() -> Self {
63        Self {
64            real_time_metrics: true,
65            predictive_analytics: true,
66            aggregation_interval: Duration::from_secs(60),
67            analysis_depth: Duration::from_secs(3600), // 1 hour
68            prediction_horizon: Duration::from_secs(1800), // 30 minutes
69        }
70    }
71}
72
73/// Alert thresholds configuration
74#[derive(Debug, Clone, Serialize, Deserialize)]
75pub struct AlertThresholds {
76    /// CPU utilization threshold
77    pub cpu_threshold: f64,
78    /// Memory utilization threshold
79    pub memory_threshold: f64,
80    /// Queue length threshold
81    pub queue_threshold: usize,
82    /// Error rate threshold
83    pub error_rate_threshold: f64,
84    /// Response time threshold
85    pub response_time_threshold: Duration,
86    /// Hardware failure threshold
87    pub hardware_failure_threshold: f64,
88}
89
90impl Default for AlertThresholds {
91    fn default() -> Self {
92        Self {
93            cpu_threshold: 0.85,
94            memory_threshold: 0.90,
95            queue_threshold: 100,
96            error_rate_threshold: 0.05,
97            response_time_threshold: Duration::from_secs(300),
98            hardware_failure_threshold: 0.01,
99        }
100    }
101}
102
103/// Monitor configuration
104#[derive(Debug, Clone, Serialize, Deserialize)]
105pub struct MonitorConfig {
106    /// Monitoring frequency
107    pub monitoring_frequency: Duration,
108    /// Metrics to collect
109    pub metrics_to_collect: Vec<MetricType>,
110    /// Alert configuration
111    pub alert_config: AlertConfig,
112    /// Data retention period
113    pub data_retention: Duration,
114}
115
116impl Default for MonitorConfig {
117    fn default() -> Self {
118        Self {
119            monitoring_frequency: Duration::from_secs(60),
120            metrics_to_collect: vec![MetricType::All],
121            alert_config: AlertConfig {
122                alerts_enabled: true,
123                alert_channels: vec![AlertChannel::Dashboard],
124                alert_rules: vec![],
125                escalation_policy: EscalationPolicy {
126                    levels: vec![],
127                    auto_acknowledge_timeout: Duration::from_secs(300),
128                    max_level: 3,
129                },
130            },
131            data_retention: Duration::from_secs(7 * 24 * 3600), // 7 days
132        }
133    }
134}
135
136/// Alert configuration
137#[derive(Debug, Clone, Serialize, Deserialize)]
138pub struct AlertConfig {
139    /// Enable alerts
140    pub alerts_enabled: bool,
141    /// Alert delivery channels
142    pub alert_channels: Vec<AlertChannel>,
143    /// Alert rules
144    pub alert_rules: Vec<AlertRule>,
145    /// Escalation policy
146    pub escalation_policy: EscalationPolicy,
147}
148
149/// Alert rule definition
150#[derive(Debug, Clone, Serialize, Deserialize)]
151pub struct AlertRule {
152    /// Rule name
153    pub name: String,
154    /// Condition expression
155    pub condition: String,
156    /// Threshold value
157    pub threshold: f64,
158    /// Alert severity
159    pub severity: super::types::AlertSeverity,
160    /// Cooldown period
161    pub cooldown: Duration,
162}
163
164/// Escalation policy
165#[derive(Debug, Clone, Serialize, Deserialize)]
166pub struct EscalationPolicy {
167    /// Escalation levels
168    pub levels: Vec<EscalationLevel>,
169    /// Auto-acknowledge timeout
170    pub auto_acknowledge_timeout: Duration,
171    /// Maximum escalation level
172    pub max_level: usize,
173}
174
175/// Escalation level definition
176#[derive(Debug, Clone, Serialize, Deserialize)]
177pub struct EscalationLevel {
178    /// Level number
179    pub level: usize,
180    /// Time before escalation
181    pub delay: Duration,
182    /// Notification targets
183    pub targets: Vec<String>,
184    /// Channels for this level
185    pub channels: Vec<AlertChannel>,
186}