LCOV - code coverage report
Current view: top level - compute_tools/src/http/routes - lfc.rs (source / functions) Coverage Total Hit
Test: 472031e0b71f3195f7f21b1f2b20de09fd07bb56.info Lines: 0.0 % 22 0
Test Date: 2025-05-26 10:37:33 Functions: 0.0 % 8 0

            Line data    Source code
       1              : use crate::compute_prewarm::LfcPrewarmStateWithProgress;
       2              : use crate::http::JsonResponse;
       3              : use axum::response::{IntoResponse, Response};
       4              : use axum::{Json, http::StatusCode};
       5              : use compute_api::responses::LfcOffloadState;
       6              : type Compute = axum::extract::State<std::sync::Arc<crate::compute::ComputeNode>>;
       7              : 
       8            0 : pub(in crate::http) async fn prewarm_state(compute: Compute) -> Json<LfcPrewarmStateWithProgress> {
       9            0 :     Json(compute.lfc_prewarm_state().await)
      10            0 : }
      11              : 
      12              : // Following functions are marked async for axum, as it's more convenient than wrapping these
      13              : // in async lambdas at call site
      14              : 
      15            0 : pub(in crate::http) async fn offload_state(compute: Compute) -> Json<LfcOffloadState> {
      16            0 :     Json(compute.lfc_offload_state())
      17            0 : }
      18              : 
      19            0 : pub(in crate::http) async fn prewarm(compute: Compute) -> Response {
      20            0 :     if compute.prewarm_lfc() {
      21            0 :         StatusCode::ACCEPTED.into_response()
      22              :     } else {
      23            0 :         JsonResponse::error(
      24            0 :             StatusCode::TOO_MANY_REQUESTS,
      25            0 :             "Multiple requests for prewarm are not allowed",
      26            0 :         )
      27              :     }
      28            0 : }
      29              : 
      30            0 : pub(in crate::http) async fn offload(compute: Compute) -> Response {
      31            0 :     if compute.offload_lfc() {
      32            0 :         StatusCode::ACCEPTED.into_response()
      33              :     } else {
      34            0 :         JsonResponse::error(
      35            0 :             StatusCode::TOO_MANY_REQUESTS,
      36            0 :             "Multiple requests for prewarm offload are not allowed",
      37            0 :         )
      38              :     }
      39            0 : }
        

Generated by: LCOV version 2.1-beta