use a3s_box_core::scale::{InstanceHealth, InstanceState};
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
mod api;
mod authority;
mod catalog;
mod endpoints;
mod manager;
mod reconciler;
mod registry;
#[cfg(test)]
mod tests;
pub use api::{scale_router, serve_scale_api, ScaleApiState, SharedScaleAuthority};
pub use authority::{DurableScaleAuthority, ScaleAuthorityError};
pub use catalog::{
ScaleCatalogError, ScaleServiceCatalog, SCALE_GUEST_PORT_LABEL, SCALE_MANAGED_LABEL,
SCALE_SERVICE_LABEL, SCALE_SLOT_LABEL, SCALE_TEMPLATE_DIGEST_LABEL,
};
pub use endpoints::{ScaleEndpointConfig, ScaleEndpointConfigError};
pub use manager::ScaleManager;
pub use reconciler::{
LocalScaleReconciler, ScaleReconcileError, ScaleReconcileObservation, ScaleReconcileReport,
};
pub use registry::InstanceRegistry;
#[derive(Debug, Clone)]
pub(super) struct ServiceInstances {
pub(super) target_replicas: u32,
pub(super) instances: Vec<TrackedInstance>,
}
#[derive(Debug, Clone)]
pub(super) struct TrackedInstance {
pub(super) id: String,
pub(super) state: InstanceState,
pub(super) created_at: DateTime<Utc>,
pub(super) ready_at: Option<DateTime<Utc>>,
pub(super) endpoint: Option<String>,
pub(super) health: InstanceHealth,
}
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ServiceHealth {
pub active_instances: u32,
pub ready_instances: u32,
pub busy_instances: u32,
pub avg_cpu_percent: Option<f32>,
pub total_memory_bytes: u64,
pub total_inflight_requests: u32,
pub unhealthy_instances: u32,
}