"""健康检查端点(data-ana 服务)。 - GET /healthz:liveness,仅返回进程存活。 - GET /readyz:readiness,简化版返回 ok + TODO,待补全 ClickHouse 连通性校验。 集成说明:在 FastAPI app 中挂载 router: from health import router as health_router app.include_router(health_router) """ from datetime import UTC, datetime from fastapi import APIRouter router = APIRouter() SERVICE_NAME = "data-ana" @router.get("/healthz") async def healthz() -> dict: return {"status": "ok", "service": SERVICE_NAME} @router.get("/readyz") async def readyz() -> dict: # TODO: 校验关键依赖 # 1. ClickHouse 连通性:clickhouse_client.execute("SELECT 1") # 依赖客户端就绪后再补全检查逻辑,失败时返回 503。 return { "status": "ok", "service": SERVICE_NAME, "timestamp": datetime.now(UTC).isoformat(), }