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::checker::check_writability;
9 : use crate::compute::ComputeNode;
10 : use crate::http::JsonResponse;
11 :
12 : /// Check that the compute is currently running.
13 0 : pub(in crate::http) async fn is_writable(State(compute): State<Arc<ComputeNode>>) -> Response {
14 0 : let status = compute.get_status();
15 0 : if status != ComputeStatus::Running {
16 0 : return JsonResponse::invalid_status(status);
17 0 : }
18 0 :
19 0 : match check_writability(&compute).await {
20 0 : Ok(_) => JsonResponse::success(StatusCode::OK, true),
21 0 : Err(e) => JsonResponse::error(StatusCode::INTERNAL_SERVER_ERROR, e),
22 : }
23 0 : }
|