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