-
Notifications
You must be signed in to change notification settings - Fork 6
/
health.rs
39 lines (34 loc) · 1018 Bytes
/
health.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use std::sync::Arc;
use axum::{extract::Extension, http::StatusCode, response::IntoResponse};
use tracing::error;
use crate::module::{Modules, ModulesExt};
pub async fn hc() -> impl IntoResponse {
tracing::debug!("Access health check endpoint from user!");
StatusCode::NO_CONTENT
}
pub async fn hc_db(
Extension(module): Extension<Arc<Modules>>,
) -> Result<impl IntoResponse, StatusCode> {
module
.health_check_use_case()
.diagnose_db_conn()
.await
.map(|_| StatusCode::NO_CONTENT)
.map_err(|err| {
error!("{:?}", err);
StatusCode::SERVICE_UNAVAILABLE
})
}
pub async fn hc_dynamo(
Extension(module): Extension<Arc<Modules>>,
) -> Result<impl IntoResponse, StatusCode> {
module
.health_check_use_case()
.diagnose_dynamo_db_conn()
.await
.map(|_| StatusCode::NO_CONTENT)
.map_err(|err| {
error!("{:?}", err);
StatusCode::SERVICE_UNAVAILABLE
})
}