pub async fn get_running_instances(
pool: &Pool<MySql>,
app_id: i64,
) -> Result<Vec<Instance>>
Expand description
Retrieves all running instances for a specific application.
This function fetches all instances in the ‘running’ state for an application, ordered by creation time with the most recent first. It’s useful for monitoring active compute resources and managing application scaling.
§Arguments
pool
- Database connection pool for executing the queryapp_id
- Unique identifier of the application whose running instances to retrieve
§Returns
Ok(Vec<Instance>)
- Successfully retrieved list of running instancesErr(anyhow::Error)
- Failed to fetch running instances
§Use Cases
Common use cases include:
- Monitoring active compute resources
- Load balancing traffic across running instances
- Determining if auto-scaling is necessary
- Checking application health through instance distribution