refactor: Keep code DRY in health endpoint
This commit is contained in:
parent
a8dab3019e
commit
b75aa6f9ad
1 changed files with 2 additions and 12 deletions
|
|
@ -241,16 +241,6 @@ class HealthChecker:
|
||||||
"""Get comprehensive health status."""
|
"""Get comprehensive health status."""
|
||||||
components = {}
|
components = {}
|
||||||
|
|
||||||
# Critical services
|
|
||||||
critical_components = [
|
|
||||||
"relational_db",
|
|
||||||
"vector_db",
|
|
||||||
"graph_db",
|
|
||||||
"file_storage",
|
|
||||||
"llm_provider",
|
|
||||||
"embedding_service",
|
|
||||||
]
|
|
||||||
|
|
||||||
critical_checks = [
|
critical_checks = [
|
||||||
("relational_db", self.check_relational_db()),
|
("relational_db", self.check_relational_db()),
|
||||||
("vector_db", self.check_vector_db()),
|
("vector_db", self.check_vector_db()),
|
||||||
|
|
@ -296,11 +286,11 @@ class HealthChecker:
|
||||||
else:
|
else:
|
||||||
components[name] = result
|
components[name] = result
|
||||||
|
|
||||||
|
critical_comps = [check[0] for check in critical_checks]
|
||||||
# Determine overall status
|
# Determine overall status
|
||||||
critical_unhealthy = any(
|
critical_unhealthy = any(
|
||||||
comp.status == HealthStatus.UNHEALTHY
|
comp.status == HealthStatus.UNHEALTHY and name in critical_comps
|
||||||
for name, comp in components.items()
|
for name, comp in components.items()
|
||||||
if name in critical_components
|
|
||||||
)
|
)
|
||||||
|
|
||||||
has_degraded = any(comp.status == HealthStatus.DEGRADED for comp in components.values())
|
has_degraded = any(comp.status == HealthStatus.DEGRADED for comp in components.values())
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue