clippy + fmt

This commit is contained in:
Quentin de Quelen
2020-04-10 19:05:05 +02:00
committed by qdequele
parent 22fbff98d4
commit 6a1f73a304
17 changed files with 633 additions and 339 deletions

View File

@ -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())