LCOV - code coverage report
Current view: top level - compute_tools/src/http/routes - hadron_liveness_probe.rs (source / functions) Coverage Total Hit
Test: c8f8d331b83562868d9054d9e0e68f866772aeaa.info Lines: 0.0 % 12 0
Test Date: 2025-07-26 17:20:05 Functions: 0.0 % 2 0

            Line data    Source code
       1              : use crate::pg_isready::pg_isready;
       2              : use crate::{compute::ComputeNode, http::JsonResponse};
       3              : use axum::{extract::State, http::StatusCode, response::Response};
       4              : use std::sync::Arc;
       5              : 
       6              : /// NOTE: NOT ENABLED YET
       7              : /// Detect if the compute is alive.
       8              : /// Called by the liveness probe of the compute container.
       9            0 : pub(in crate::http) async fn hadron_liveness_probe(
      10            0 :     State(compute): State<Arc<ComputeNode>>,
      11            0 : ) -> Response {
      12            0 :     let port = match compute.params.connstr.port() {
      13            0 :         Some(port) => port,
      14              :         None => {
      15            0 :             return JsonResponse::error(
      16              :                 StatusCode::INTERNAL_SERVER_ERROR,
      17              :                 "Failed to get the port from the connection string",
      18              :             );
      19              :         }
      20              :     };
      21            0 :     match pg_isready(&compute.params.pg_isready_bin, port) {
      22              :         Ok(_) => {
      23              :             // The connection is successful, so the compute is alive.
      24              :             // Return a 200 OK response.
      25            0 :             JsonResponse::success(StatusCode::OK, "ok")
      26              :         }
      27            0 :         Err(e) => {
      28            0 :             tracing::error!("Hadron liveness probe failed: {}", e);
      29              :             // The connection failed, so the compute is not alive.
      30              :             // Return a 500 Internal Server Error response.
      31            0 :             JsonResponse::error(StatusCode::INTERNAL_SERVER_ERROR, e)
      32              :         }
      33              :     }
      34            0 : }
        

Generated by: LCOV version 2.1-beta