use std::collections::BTreeMap;
use std::sync::Arc;
use std::time::Instant;
use crate::route_registry::RouteInfo;
use crate::ProviderSummary;
#[derive(Clone, Debug)]
pub struct AdminSnapshot {
pub providers: Vec<ProviderSummary>,
pub routes: Vec<RouteInfo>,
pub metadata: BTreeMap<String, BTreeMap<String, String>>,
pub uptime_ms: u128,
pub version: &'static str,
}
impl AdminSnapshot {
pub fn capture(providers: Vec<ProviderSummary>, version: &'static str) -> Arc<Self> {
let routes = crate::route_registry::RouteRegistry::list();
let metadata = crate::metadata::MetadataRegistry::snapshot();
Arc::new(Self {
providers,
routes,
metadata,
uptime_ms: process_uptime_ms(),
version,
})
}
}
fn process_uptime_ms() -> u128 {
static START: std::sync::OnceLock<Instant> = std::sync::OnceLock::new();
let start = START.get_or_init(Instant::now);
start.elapsed().as_millis()
}