Summary
GET /api/health always returns HTTP 200, even when DataCache hasn't finished its initial load (e.g. immediately after startup, or if the UK Gov API is down). Load balancers and uptime monitors will consider the service healthy when it isn't.
Location
File: backend/src/main/kotlin/uk/co/fueller/backend/Routes.kt
What to change
- Add a
isReady(): Boolean method to DataCache that returns true only when at least one station is loaded
- In the health route:
get("/api/health") {
if (DataCache.isReady()) {
call.respond(HttpStatusCode.OK, mapOf("status" to "ok", "stations" to DataCache.stationCount()))
} else {
call.respond(HttpStatusCode.ServiceUnavailable, mapOf("status" to "loading"))
}
}
Workstream: WS1 Phase 1B
Summary
GET /api/healthalways returns HTTP 200, even whenDataCachehasn't finished its initial load (e.g. immediately after startup, or if the UK Gov API is down). Load balancers and uptime monitors will consider the service healthy when it isn't.Location
File:
backend/src/main/kotlin/uk/co/fueller/backend/Routes.ktWhat to change
isReady(): Booleanmethod toDataCachethat returnstrueonly when at least one station is loadedWorkstream: WS1 Phase 1B