app_autoscaler_agent - OmniCloudOrg/OmniOrchestrator GitHub Wiki
Path: src/app_autoscaler/agent.rs
pub trait Agent: Send + Sync + std::fmt::Debug {
/// Get the unique ID of this agent
async fn id(&self) -> String;
/// Get the nodes managed by this agent
async fn get_nodes(&self) -> Result<Vec<Node>, AutoscalerError>;
/// Get information about a specific node
async fn get_node(&self, node_id: &str) -> Result<Node, AutoscalerError>;
/// Create a new app instance on a specific node
async fn create_instance(&self, node_id: &str, name: &str, cpu: u32, memory: u32, storage: u32)
-> Result<AppInstance, AutoscalerError>;
/// Terminate an app instance
async fn terminate_instance(&self, instance_id: &str) -> Result<(), AutoscalerError>;
/// Get information about a specific app instance
async fn get_instance(&self, instance_id: &str) -> Result<AppInstance, AutoscalerError>;
/// Get all app instances managed by this agent
async fn get_instances(&self) -> Result<Vec<AppInstance>, AutoscalerError>;
/// Get metrics for a specific app instance
async fn get_instance_metrics(&self, instance_id: &str) -> Result<HashMap<String, f32>, AutoscalerError>;
}
Interface for an agent that manages app instance operations on nodes
pub struct CloudAgent {
/// Unique ID of this agent
id: String,
/// Name of the cloud provider
provider: String,
/// Region for this cloud provider
region: String,
/// Simulated nodes for this agent
nodes: Arc<Mutex<HashMap<String, Node>>>,
/// Simulated app instances for this agent
instances: Arc<Mutex<HashMap<String, AppInstance>>>,
}
Implementation of a cloud agent (AWS, Azure, GCP)
pub fn new(id: String, provider: String, region: String) -> Self {
let mut nodes = HashMap::new();
Create a new cloud agent