Files
Edu/services/data-ana/src/health/health.py
2026-07-08 12:52:33 +08:00

36 lines
925 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""健康检查端点data-ana 服务)。
- GET /healthzliveness仅返回进程存活。
- GET /readyzreadiness简化版返回 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(),
}