撮合引擎健康状态
描述
返回现货撮合引擎的存活状态。适用于负载均衡器和监控面板的探活检查;无需鉴权。
HTTP 请求
GET /spot/health (公开 (无需鉴权))
权重
0 — 当前公开行情接口对单个 IP 不设权重限制 (MVP)。
响应示例
200 OK
{
"engine": "running",
"queue_depth": 0,
"books_loaded": 1
}
| 字段 | 取值 | 说明 |
|---|---|---|
engine | running / disabled | running — 引擎任务存活并接受指令。disabled — 服务器以 SPOT_TRADING_ENABLED=false 启动;不进行撮合。 |
queue_depth | 整数 | 引擎 mpsc 命令积压队列 的当前深度。健康状态:0 或个位数。持续偏高表示存在负载问题。 |
books_loaded | 整数 | 内存订单簿数量。MVP:engine=running 时为 1,engine=disabled 时为 0。 |
错误响应
此接口始终返回 200 OK。引擎处于 disabled 状态时,相关信息体现在响应体中,而非 HTTP 状态码,因此探活程序无需解析响应体即可检测基本可达性。
| HTTP | error |
|---|---|
500 | (内部 panic——极少发生) |
完整列表:错误代码。
代码示例
cURL
curl -s "https://api-sepolia.p99.world/api/v1/spot/health"
Python
import requests
BASE = "https://api-sepolia.p99.world/api/v1"
health = requests.get(f"{BASE}/spot/health").json()
print("engine:", health["engine"],
"| queue_depth:", health["queue_depth"],
"| books_loaded:", health["books_loaded"])
if health["engine"] != "running":
print("WARNING: spot engine is not running")
elif health["queue_depth"] > 100:
print("WARNING: engine queue_depth elevated:", health["queue_depth"])