mirror of
https://github.com/neondatabase/neon.git
synced 2026-05-25 17:10:38 +00:00
This is a refactor to create better abstractions related to our management server. It cleans up the code, and prepares everything for authorized communication to and from the control plane. Signed-off-by: Tristan Partin <tristan@neon.tech>
21 lines
698 B
Rust
21 lines
698 B
Rust
use std::sync::Arc;
|
|
|
|
use axum::{extract::State, response::Response};
|
|
use compute_api::responses::ComputeStatus;
|
|
use http::StatusCode;
|
|
|
|
use crate::{checker::check_writability, compute::ComputeNode, http::JsonResponse};
|
|
|
|
/// Check that the compute is currently running.
|
|
pub(in crate::http) async fn is_writable(State(compute): State<Arc<ComputeNode>>) -> Response {
|
|
let status = compute.get_status();
|
|
if status != ComputeStatus::Running {
|
|
return JsonResponse::invalid_status(status);
|
|
}
|
|
|
|
match check_writability(&compute).await {
|
|
Ok(_) => JsonResponse::success(StatusCode::OK, true),
|
|
Err(e) => JsonResponse::error(StatusCode::INTERNAL_SERVER_ERROR, e),
|
|
}
|
|
}
|