Compare commits
1 Commits
d9a21bf94b
...
32d0c2aa1e
| Author | SHA1 | Date | |
|---|---|---|---|
| 32d0c2aa1e |
@@ -186,31 +186,31 @@ async fn health(query: web::Query<HealthQuery>) -> impl Responder {
|
|||||||
let all_passed = check_results.iter().all(|c| c.passed);
|
let all_passed = check_results.iter().all(|c| c.passed);
|
||||||
|
|
||||||
if all_passed {
|
if all_passed {
|
||||||
info!(
|
info!(
|
||||||
"All health checks passed for node '{}' in {}ms",
|
"All health checks passed for node '{}' in {}ms",
|
||||||
node_name, total_duration_ms
|
node_name, total_duration_ms
|
||||||
);
|
);
|
||||||
HttpResponse::Ok().json(HealthStatus {
|
HttpResponse::Ok().json(HealthStatus {
|
||||||
status: "ready".to_string(),
|
status: "ready".to_string(),
|
||||||
checks: check_results,
|
checks: check_results,
|
||||||
total_duration_ms,
|
total_duration_ms,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
let failed_checks: Vec<&str> = check_results
|
let failed_checks: Vec<&str> = check_results
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|c| !c.passed)
|
.filter(|c| !c.passed)
|
||||||
.map(|c| c.name.as_str())
|
.map(|c| c.name.as_str())
|
||||||
.collect();
|
.collect();
|
||||||
warn!(
|
warn!(
|
||||||
"Health checks failed for node '{}' in {}ms: {:?}",
|
"Health checks failed for node '{}' in {}ms: {:?}",
|
||||||
node_name, total_duration_ms, failed_checks
|
node_name, total_duration_ms, failed_checks
|
||||||
);
|
);
|
||||||
HttpResponse::ServiceUnavailable().json(HealthStatus {
|
HttpResponse::ServiceUnavailable().json(HealthStatus {
|
||||||
status: "not-ready".to_string(),
|
status: "not-ready".to_string(),
|
||||||
checks: check_results,
|
checks: check_results,
|
||||||
total_duration_ms,
|
total_duration_ms,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_web::main]
|
#[actix_web::main]
|
||||||
|
|||||||
Reference in New Issue
Block a user