Serve single and batch CLOB order books over HTTP

This commit is contained in:
2026-12-03 07:52:06 +08:00
parent 5892772671
commit 5dde2cd28e
11 changed files with 452 additions and 11 deletions
+21
View File
@@ -79,3 +79,24 @@ sequenceDiagram
```
[订阅报文样例](../../docs/examples/market-ws.txt)逐行发送为文本帧。客户端可每 10 秒发送一次 `PING`。本地按 100 毫秒间隔检查新批次,单页最多 64 个批次,每个进程最多接纳 128 个同时连接的会话。这些是本地实现参数。慢连接的网络写入在释放 Exchange 锁后进行。
## 盘口 HTTP
`cli DATABASE --market-http 127.0.0.1:9002` 启动公开盘口读取服务。可与写入会话和 WebSocket 服务共用数据库文件。[HTTP 请求样例](../../docs/examples/clob-http.http)
```mermaid
flowchart LR
main["main.rs"] --> http["market_http.rs"]
http --> api["exchange::Exchange::public_books"]
```
```mermaid
sequenceDiagram
participant C as SDK
participant H as market_http
participant E as Exchange
C->>H: GET /book?token_id=... 或 POST /books
H->>E: 提交本次请求的资产 ID
E-->>H: 一个数据库快照中的盘口列表
H-->>C: 单盘 JSON 对象或批量 JSON 数组
```