llm_optimizer_processor/actuator/
traits.rs1use async_trait::async_trait;
4
5use super::error::{ActuatorError, ActuatorResult, ActuatorState};
6use super::types::{
7 ActuatorStats, DeploymentRequest, DeploymentStatus, HealthCheckResult, RollbackRequest,
8 RollbackResult, SystemMetrics,
9};
10use crate::decision::Decision;
11
12#[async_trait]
14pub trait Actuator: Send + Sync {
15 fn name(&self) -> &str;
17
18 fn state(&self) -> ActuatorState;
20
21 async fn start(&mut self) -> ActuatorResult<()>;
23
24 async fn stop(&mut self) -> ActuatorResult<()>;
26
27 async fn deploy(&mut self, request: DeploymentRequest) -> ActuatorResult<DeploymentStatus>;
35
36 async fn get_deployment_status(&self, deployment_id: &str) -> ActuatorResult<DeploymentStatus>;
38
39 async fn rollback(&mut self, request: RollbackRequest) -> ActuatorResult<RollbackResult>;
41
42 async fn health_check(&self) -> ActuatorResult<Vec<HealthCheckResult>>;
44
45 fn get_stats(&self) -> ActuatorStats;
47
48 async fn reset(&mut self) -> ActuatorResult<()>;
50}
51
52#[async_trait]
54pub trait CanaryDeployment: Send + Sync {
55 async fn start_canary(
57 &mut self,
58 request: DeploymentRequest,
59 ) -> ActuatorResult<DeploymentStatus>;
60
61 async fn promote(&mut self, deployment_id: &str) -> ActuatorResult<DeploymentStatus>;
63
64 async fn complete(&mut self, deployment_id: &str) -> ActuatorResult<DeploymentStatus>;
66
67 async fn abort(&mut self, deployment_id: &str) -> ActuatorResult<RollbackResult>;
69
70 async fn get_status(&self, deployment_id: &str) -> ActuatorResult<DeploymentStatus>;
72
73 async fn can_promote(&self, deployment_id: &str) -> ActuatorResult<bool>;
75}
76
77#[async_trait]
79pub trait HealthMonitor: Send + Sync {
80 async fn check_health(
82 &self,
83 deployment_id: &str,
84 metrics: &SystemMetrics,
85 ) -> ActuatorResult<Vec<HealthCheckResult>>;
86
87 async fn should_rollback(
89 &self,
90 deployment_id: &str,
91 status: &DeploymentStatus,
92 ) -> ActuatorResult<bool>;
93
94 async fn get_health_summary(
96 &self,
97 deployment_id: &str,
98 ) -> ActuatorResult<super::types::HealthStatus>;
99}
100
101#[async_trait]
103pub trait ConfigurationManager: Send + Sync {
104 async fn apply_config(
106 &mut self,
107 changes: &[crate::decision::ConfigChange],
108 ) -> ActuatorResult<()>;
109
110 async fn revert_config(
112 &mut self,
113 changes: &[crate::decision::ConfigChange],
114 ) -> ActuatorResult<()>;
115
116 async fn create_snapshot(&mut self) -> ActuatorResult<super::types::ConfigurationSnapshot>;
118
119 async fn restore_snapshot(&mut self, snapshot_id: &str) -> ActuatorResult<()>;
121
122 async fn get_config(&self) -> ActuatorResult<std::collections::HashMap<String, serde_json::Value>>;
124
125 async fn validate_config(
127 &self,
128 changes: &[crate::decision::ConfigChange],
129 ) -> ActuatorResult<()>;
130}
131
132#[async_trait]
134pub trait TrafficSplitter: Send + Sync {
135 async fn route_request(&self, request_id: &str, canary_percent: f64) -> ActuatorResult<bool>;
137
138 fn get_routing_stats(&self) -> std::collections::HashMap<String, u64>;
140}