ruvector_server/routes/
health.rs

1//! Health check endpoints
2
3use crate::{state::AppState, Result};
4use axum::{extract::State, response::IntoResponse, Json};
5use serde::Serialize;
6
7/// Health status response
8#[derive(Debug, Serialize)]
9pub struct HealthStatus {
10    /// Server status
11    pub status: String,
12}
13
14/// Readiness status response
15#[derive(Debug, Serialize)]
16pub struct ReadinessStatus {
17    /// Server status
18    pub status: String,
19    /// Number of collections
20    pub collections: usize,
21    /// Total number of points across all collections
22    pub total_points: usize,
23}
24
25/// Simple health check endpoint
26///
27/// GET /health
28pub async fn health_check() -> Result<impl IntoResponse> {
29    Ok(Json(HealthStatus {
30        status: "healthy".to_string(),
31    }))
32}
33
34/// Readiness check endpoint with stats
35///
36/// GET /ready
37pub async fn readiness(State(state): State<AppState>) -> Result<impl IntoResponse> {
38    let collections_count = state.collection_count();
39
40    // Note: VectorDB doesn't expose count directly, so we report collections only
41    Ok(Json(ReadinessStatus {
42        status: "ready".to_string(),
43        collections: collections_count,
44        total_points: 0, // Would require tracking or querying each DB
45    }))
46}