Line data    Source code 
       1              : use std::sync::Arc;
       2              : 
       3              : use axum::{extract::State, response::Response};
       4              : use compute_api::responses::ComputeStatus;
       5              : use http::StatusCode;
       6              : 
       7              : use crate::{compute::ComputeNode, http::JsonResponse};
       8              : 
       9              : /// Collect current Postgres usage insights.
      10            0 : pub(in crate::http) async fn get_insights(State(compute): State<Arc<ComputeNode>>) -> Response {
      11            0 :     let status = compute.get_status();
      12            0 :     if status != ComputeStatus::Running {
      13            0 :         return JsonResponse::invalid_status(status);
      14            0 :     }
      15              : 
      16            0 :     let insights = compute.collect_insights().await;
      17            0 :     JsonResponse::success(StatusCode::OK, insights)
      18            0 : }
        
               |