use async_trait::async_trait;
use super::error::{ActuatorError, ActuatorResult, ActuatorState};
use super::types::{
ActuatorStats, DeploymentRequest, DeploymentStatus, HealthCheckResult, RollbackRequest,
RollbackResult, SystemMetrics,
};
use crate::decision::Decision;
#[async_trait]
pub trait Actuator: Send + Sync {
fn name(&self) -> &str;
fn state(&self) -> ActuatorState;
async fn start(&mut self) -> ActuatorResult<()>;
async fn stop(&mut self) -> ActuatorResult<()>;
async fn deploy(&mut self, request: DeploymentRequest) -> ActuatorResult<DeploymentStatus>;
async fn get_deployment_status(&self, deployment_id: &str) -> ActuatorResult<DeploymentStatus>;
async fn rollback(&mut self, request: RollbackRequest) -> ActuatorResult<RollbackResult>;
async fn health_check(&self) -> ActuatorResult<Vec<HealthCheckResult>>;
fn get_stats(&self) -> ActuatorStats;
async fn reset(&mut self) -> ActuatorResult<()>;
}
#[async_trait]
pub trait CanaryDeployment: Send + Sync {
async fn start_canary(
&mut self,
request: DeploymentRequest,
) -> ActuatorResult<DeploymentStatus>;
async fn promote(&mut self, deployment_id: &str) -> ActuatorResult<DeploymentStatus>;
async fn complete(&mut self, deployment_id: &str) -> ActuatorResult<DeploymentStatus>;
async fn abort(&mut self, deployment_id: &str) -> ActuatorResult<RollbackResult>;
async fn get_status(&self, deployment_id: &str) -> ActuatorResult<DeploymentStatus>;
async fn can_promote(&self, deployment_id: &str) -> ActuatorResult<bool>;
}
#[async_trait]
pub trait HealthMonitor: Send + Sync {
async fn check_health(
&self,
deployment_id: &str,
metrics: &SystemMetrics,
) -> ActuatorResult<Vec<HealthCheckResult>>;
async fn should_rollback(
&self,
deployment_id: &str,
status: &DeploymentStatus,
) -> ActuatorResult<bool>;
async fn get_health_summary(
&self,
deployment_id: &str,
) -> ActuatorResult<super::types::HealthStatus>;
}
#[async_trait]
pub trait ConfigurationManager: Send + Sync {
async fn apply_config(
&mut self,
changes: &[crate::decision::ConfigChange],
) -> ActuatorResult<()>;
async fn revert_config(
&mut self,
changes: &[crate::decision::ConfigChange],
) -> ActuatorResult<()>;
async fn create_snapshot(&mut self) -> ActuatorResult<super::types::ConfigurationSnapshot>;
async fn restore_snapshot(&mut self, snapshot_id: &str) -> ActuatorResult<()>;
async fn get_config(&self) -> ActuatorResult<std::collections::HashMap<String, serde_json::Value>>;
async fn validate_config(
&self,
changes: &[crate::decision::ConfigChange],
) -> ActuatorResult<()>;
}
#[async_trait]
pub trait TrafficSplitter: Send + Sync {
async fn route_request(&self, request_id: &str, canary_percent: f64) -> ActuatorResult<bool>;
fn get_routing_stats(&self) -> std::collections::HashMap<String, u64>;
}