a3s_box_runtime/scale/
mod.rs1use a3s_box_core::scale::{InstanceHealth, InstanceState};
7use chrono::{DateTime, Utc};
8use serde::{Deserialize, Serialize};
9
10mod api;
11mod authority;
12mod catalog;
13mod endpoints;
14mod manager;
15mod reconciler;
16mod registry;
17
18#[cfg(test)]
19mod tests;
20
21pub use api::{scale_router, serve_scale_api, ScaleApiState, SharedScaleAuthority};
23pub use authority::{DurableScaleAuthority, ScaleAuthorityError};
24pub use catalog::{
25 ScaleCatalogError, ScaleServiceCatalog, SCALE_GUEST_PORT_LABEL, SCALE_MANAGED_LABEL,
26 SCALE_SERVICE_LABEL, SCALE_SLOT_LABEL, SCALE_TEMPLATE_DIGEST_LABEL,
27};
28pub use endpoints::{ScaleEndpointConfig, ScaleEndpointConfigError};
29pub use manager::ScaleManager;
30pub use reconciler::{
31 LocalScaleReconciler, ScaleReconcileError, ScaleReconcileObservation, ScaleReconcileReport,
32};
33pub use registry::InstanceRegistry;
34
35#[derive(Debug, Clone)]
37pub(super) struct ServiceInstances {
38 pub(super) target_replicas: u32,
40 pub(super) instances: Vec<TrackedInstance>,
42}
43
44#[derive(Debug, Clone)]
46pub(super) struct TrackedInstance {
47 pub(super) id: String,
48 pub(super) state: InstanceState,
49 pub(super) created_at: DateTime<Utc>,
50 pub(super) ready_at: Option<DateTime<Utc>>,
51 pub(super) endpoint: Option<String>,
52 pub(super) health: InstanceHealth,
53}
54
55#[derive(Debug, Clone, Default, Serialize, Deserialize)]
57pub struct ServiceHealth {
58 pub active_instances: u32,
60 pub ready_instances: u32,
62 pub busy_instances: u32,
64 pub avg_cpu_percent: Option<f32>,
66 pub total_memory_bytes: u64,
68 pub total_inflight_requests: u32,
70 pub unhealthy_instances: u32,
72}