sklears_compose/execution/
config.rs1use std::collections::HashMap;
7use std::time::Duration;
8
9#[derive(Debug, Clone)]
11pub struct ExecutionEngineConfig {
12 pub name: String,
14 pub default_strategy: String,
16 pub resource_constraints: ResourceConstraints,
18 pub performance_goals: PerformanceGoals,
20 pub fault_tolerance: FaultToleranceConfig,
22 pub monitoring: MonitoringConfig,
24}
25
26#[derive(Debug, Clone)]
28pub struct ResourceConstraints {
29 pub max_cpu_cores: Option<usize>,
31 pub max_memory: Option<u64>,
33 pub max_task_time: Option<Duration>,
35 pub max_concurrent_tasks: Option<usize>,
37 pub io_bandwidth: Option<IoLimits>,
39}
40
41#[derive(Debug, Clone)]
43pub struct IoLimits {
44 pub max_read_bps: u64,
45 pub max_write_bps: u64,
46 pub max_concurrent_io: usize,
47}
48
49#[derive(Debug, Clone)]
51pub struct PerformanceGoals {
52 pub target_throughput: f64,
54 pub max_latency: Duration,
56 pub target_utilization: f64,
58 pub energy_efficiency: Option<EnergyEfficiencyGoal>,
60}
61
62#[derive(Debug, Clone)]
64pub struct EnergyEfficiencyGoal {
65 pub max_power_watts: f64,
67 pub energy_budget_per_task: f64,
69}
70
71#[derive(Debug, Clone)]
73pub struct FaultToleranceConfig {
74 pub enable_retry: bool,
76 pub max_retries: usize,
78 pub backoff_strategy: BackoffStrategy,
80 pub enable_circuit_breaker: bool,
82 pub health_check: HealthCheckConfig,
84}
85
86#[derive(Debug, Clone)]
88pub enum BackoffStrategy {
89 Fixed { delay: Duration },
91 Exponential {
93 base_delay: Duration,
94 multiplier: f64,
95 },
96 Linear {
98 base_delay: Duration,
99 increment: Duration,
100 },
101 Custom { delays: Vec<Duration> },
103}
104
105#[derive(Debug, Clone)]
107pub struct HealthCheckConfig {
108 pub interval: Duration,
110 pub timeout: Duration,
112 pub failure_threshold: usize,
114 pub success_threshold: usize,
116}
117
118#[derive(Debug, Clone)]
120pub struct MonitoringConfig {
121 pub enable_metrics: bool,
123 pub metrics_interval: Duration,
125 pub enable_tracing: bool,
127 pub log_level: LogLevel,
129 pub metric_tags: HashMap<String, String>,
131}
132
133#[derive(Debug, Clone)]
135pub enum LogLevel {
136 Trace,
138 Debug,
140 Info,
142 Warn,
144 Error,
146}
147
148#[derive(Debug, Clone)]
150pub struct StrategyConfig {
151 pub name: String,
153 pub parameters: HashMap<String, ParameterValue>,
155 pub resource_allocation: StrategyResourceAllocation,
157 pub performance_tuning: PerformanceTuning,
159}
160
161#[derive(Debug, Clone)]
163pub enum ParameterValue {
164 String(String),
166 Integer(i64),
168 Float(f64),
170 Boolean(bool),
172 Duration(Duration),
174 List(Vec<ParameterValue>),
176}
177
178#[derive(Debug, Clone)]
180pub struct StrategyResourceAllocation {
181 pub cpu_cores: f64,
183 pub memory_bytes: u64,
185 pub priority: u32,
187}
188
189#[derive(Debug, Clone)]
191pub struct PerformanceTuning {
192 pub optimization_level: OptimizationLevel,
194 pub prefetching: PrefetchingStrategy,
196 pub caching: CachingStrategy,
198 pub load_balancing: LoadBalancingConfig,
200}
201
202#[derive(Debug, Clone)]
204pub enum OptimizationLevel {
205 None,
206 Low,
208 Medium,
210 High,
212 Aggressive,
214}
215
216#[derive(Debug, Clone)]
218pub enum PrefetchingStrategy {
219 None,
220 Sequential,
222 Adaptive,
224 Predictive,
226}
227
228#[derive(Debug, Clone)]
230pub enum CachingStrategy {
231 None,
232 LRU,
234 LFU,
236 FIFO,
238 Adaptive,
240}
241
242#[derive(Debug, Clone)]
244pub struct LoadBalancingConfig {
245 pub enabled: bool,
247 pub algorithm: LoadBalancingAlgorithm,
249 pub rebalance_threshold: f64,
251 pub min_load_difference: f64,
253}
254
255#[derive(Debug, Clone)]
257pub enum LoadBalancingAlgorithm {
258 RoundRobin,
260 LeastLoaded,
262 WeightedRoundRobin,
264 ConsistentHashing,
266 Random,
268}
269
270impl Default for ExecutionEngineConfig {
271 fn default() -> Self {
272 Self {
273 name: "default-engine".to_string(),
274 default_strategy: "default".to_string(),
275 resource_constraints: ResourceConstraints::default(),
276 performance_goals: PerformanceGoals::default(),
277 fault_tolerance: FaultToleranceConfig::default(),
278 monitoring: MonitoringConfig::default(),
279 }
280 }
281}
282
283impl Default for ResourceConstraints {
284 fn default() -> Self {
285 Self {
286 max_cpu_cores: None,
287 max_memory: None,
288 max_task_time: Some(Duration::from_secs(300)), max_concurrent_tasks: Some(10),
290 io_bandwidth: None,
291 }
292 }
293}
294
295impl Default for PerformanceGoals {
296 fn default() -> Self {
297 Self {
298 target_throughput: 10.0, max_latency: Duration::from_millis(100),
300 target_utilization: 0.8, energy_efficiency: None,
302 }
303 }
304}
305
306impl Default for FaultToleranceConfig {
307 fn default() -> Self {
308 Self {
309 enable_retry: true,
310 max_retries: 3,
311 backoff_strategy: BackoffStrategy::Exponential {
312 base_delay: Duration::from_millis(100),
313 multiplier: 2.0,
314 },
315 enable_circuit_breaker: false,
316 health_check: HealthCheckConfig::default(),
317 }
318 }
319}
320
321impl Default for HealthCheckConfig {
322 fn default() -> Self {
323 Self {
324 interval: Duration::from_secs(30),
325 timeout: Duration::from_secs(5),
326 failure_threshold: 3,
327 success_threshold: 2,
328 }
329 }
330}
331
332impl Default for MonitoringConfig {
333 fn default() -> Self {
334 Self {
335 enable_metrics: true,
336 metrics_interval: Duration::from_secs(10),
337 enable_tracing: false,
338 log_level: LogLevel::Info,
339 metric_tags: HashMap::new(),
340 }
341 }
342}