mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-09-21 20:26:25 +00:00
clippy + fmt
This commit is contained in:
committed by
qdequele
parent
22fbff98d4
commit
6a1f73a304
@ -1,17 +1,17 @@
|
||||
use crate::error::ResponseError;
|
||||
use actix_web::{web, get, put, HttpResponse};
|
||||
use actix_web as aweb;
|
||||
use crate::Data;
|
||||
use actix_web as aweb;
|
||||
use actix_web::{get, put, web, HttpResponse};
|
||||
use heed::types::{Str, Unit};
|
||||
use serde::Deserialize;
|
||||
|
||||
const UNHEALTHY_KEY: &str = "_is_unhealthy";
|
||||
|
||||
#[get("/health")]
|
||||
pub async fn get_health(
|
||||
data: web::Data<Data>,
|
||||
) -> aweb::Result<HttpResponse> {
|
||||
let reader = data.db.main_read_txn()
|
||||
pub async fn get_health(data: web::Data<Data>) -> aweb::Result<HttpResponse> {
|
||||
let reader = data
|
||||
.db
|
||||
.main_read_txn()
|
||||
.map_err(|err| ResponseError::Internal(err.to_string()))?;
|
||||
|
||||
let common_store = data.db.common_store();
|
||||
@ -23,29 +23,33 @@ pub async fn get_health(
|
||||
Ok(HttpResponse::Ok().finish())
|
||||
}
|
||||
|
||||
pub async fn set_healthy(
|
||||
data: web::Data<Data>,
|
||||
) -> aweb::Result<HttpResponse> {
|
||||
let mut writer = data.db.main_write_txn()
|
||||
pub async fn set_healthy(data: web::Data<Data>) -> aweb::Result<HttpResponse> {
|
||||
let mut writer = data
|
||||
.db
|
||||
.main_write_txn()
|
||||
.map_err(|err| ResponseError::Internal(err.to_string()))?;
|
||||
let common_store = data.db.common_store();
|
||||
common_store.delete::<_, Str>(&mut writer, UNHEALTHY_KEY)
|
||||
common_store
|
||||
.delete::<_, Str>(&mut writer, UNHEALTHY_KEY)
|
||||
.map_err(|e| ResponseError::Internal(e.to_string()))?;
|
||||
writer.commit()
|
||||
writer
|
||||
.commit()
|
||||
.map_err(|err| ResponseError::Internal(err.to_string()))?;
|
||||
|
||||
Ok(HttpResponse::Ok().finish())
|
||||
}
|
||||
|
||||
pub async fn set_unhealthy(
|
||||
data: web::Data<Data>,
|
||||
) -> aweb::Result<HttpResponse> {
|
||||
let mut writer = data.db.main_write_txn()
|
||||
pub async fn set_unhealthy(data: web::Data<Data>) -> aweb::Result<HttpResponse> {
|
||||
let mut writer = data
|
||||
.db
|
||||
.main_write_txn()
|
||||
.map_err(|err| ResponseError::Internal(err.to_string()))?;
|
||||
let common_store = data.db.common_store();
|
||||
common_store.put::<_, Str, Unit>(&mut writer, UNHEALTHY_KEY, &())
|
||||
common_store
|
||||
.put::<_, Str, Unit>(&mut writer, UNHEALTHY_KEY, &())
|
||||
.map_err(|e| ResponseError::Internal(e.to_string()))?;
|
||||
writer.commit()
|
||||
writer
|
||||
.commit()
|
||||
.map_err(|err| ResponseError::Internal(err.to_string()))?;
|
||||
|
||||
Ok(HttpResponse::Ok().finish())
|
||||
|
Reference in New Issue
Block a user