Line data Source code
1 : use crate::http::JsonResponse;
2 : use axum::extract::Json;
3 : use http::StatusCode;
4 :
5 0 : pub(in crate::http) async fn promote(
6 0 : compute: axum::extract::State<std::sync::Arc<crate::compute::ComputeNode>>,
7 0 : Json(cfg): Json<compute_api::responses::PromoteConfig>,
8 0 : ) -> axum::response::Response {
9 0 : let state = compute.promote(cfg).await;
10 0 : if let compute_api::responses::PromoteState::Failed { error: _ } = state {
11 0 : return JsonResponse::create_response(StatusCode::INTERNAL_SERVER_ERROR, state);
12 0 : }
13 0 : JsonResponse::success(StatusCode::OK, state)
14 0 : }
|