按 docs/order-gateway.md 落地:第三个部署单元 app.gateway(:31109)承担任务队列 + 状态镜像;本地 worker 在 app.trading.worker 内,按 RAKUTEN_ORDER_GATEWAY_URL 决定是否启动。规格 §5 最关键约束已守:租约过期绝不自动重投,恢复只能 reclaim, worker 收到 lease_count>1 时先核对站点订单。 站点交互(加购/下单/付款/订单列表反查)按规格 §10 留接口缝,site_interact.py 全部 NotImplementedError,verify.py 恒返回 unknown——等真实账号实测后再填, 不写猜测的提交逻辑。 310 个测试全绿,覆盖规格 §9 验收清单 12 条;架构测试守住三方互不 import。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
24 lines
823 B
Python
24 lines
823 B
Python
"""网关健康检查路由"""
|
|
from fastapi import APIRouter, Depends
|
|
|
|
from app.gateway.container import GatewayContainer
|
|
from app.gateway.models import GatewayHealthData
|
|
from app.shared.api import ApiResponse, get_container
|
|
|
|
router = APIRouter(tags=["health"])
|
|
|
|
|
|
@router.get("/health", response_model=ApiResponse[GatewayHealthData])
|
|
async def health(
|
|
container: GatewayContainer = Depends(get_container),
|
|
) -> ApiResponse[GatewayHealthData]:
|
|
"""网关健康状态
|
|
|
|
只做规格 §4.7 的两条兜底告警:worker 失联、任务长时间无人领。
|
|
付款期限监控不在网关——本地机 7×24 在线,那套逻辑放本地。
|
|
"""
|
|
data = await container.task_queue.health_snapshot()
|
|
return ApiResponse[GatewayHealthData](
|
|
success=True, msg="success", data=data, code=0
|
|
)
|