feat: 配置列表分页与钉钉机器人分钟级排队限流

统一 sources/templates/channels/rules 列表为分页响应,避免配置增多时全量返回;按钉钉 access_token 限制每分钟发送并在超限时等待下一分钟,降低触发官方封禁风险。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-10 00:34:26 +08:00
parent 009694fee7
commit 39f3774940
27 changed files with 1447 additions and 60 deletions
+23 -4
View File
@@ -94,6 +94,7 @@ make build && ./bin/server
| `redis.*` | Redis(缓存 + 限流) | `127.0.0.1:6379` |
| `smtp.*` | 邮件发送(email 渠道) | — |
| `rate_limit.default` | 每 source 每秒请求上限 | `100` |
| `rate_limit.dingtalk_per_min` | 同一钉钉机器人(access_token)每分钟发送上限;超限排队到下一分钟 | `18`(官方 20,留余量) |
健康检查:`GET /health``{"status":"ok"}`
@@ -265,7 +266,13 @@ Regex 示例:
#### `GET /api/v1/sources` — 列表
**200**`Source[]`
Query`page`(默认 1)、`page_size`(默认 20
**200**
```json
{ "data": [ /* Source[] */ ], "total": 10, "page": 1 }
```
#### `GET /api/v1/sources/:id` — 详情
@@ -313,7 +320,11 @@ Text 模式示例:`{{.Body}}`
**201** → Template;冲突 → **409**
#### `GET /api/v1/templates` / `GET /api/v1/templates/:id`
#### `GET /api/v1/templates` — 列表
Query`page``page_size`(默认同 sources)。**200** `{ "data": Template[], "total", "page" }`
#### `GET /api/v1/templates/:id`
#### `PUT /api/v1/templates/:id` / `DELETE /api/v1/templates/:id`
@@ -387,7 +398,11 @@ SMTP 使用全局 `config.yaml` 的 `smtp` 段;支持 587 STARTTLS / 465 TLS
}
```
#### `GET /api/v1/channels` / `GET /api/v1/channels/:id`
#### `GET /api/v1/channels` — 列表
Query`page``page_size`。**200** `{ "data": Channel[], "total", "page" }`
#### `GET /api/v1/channels/:id`
#### `PUT /api/v1/channels/:id` / `DELETE /api/v1/channels/:id`
@@ -438,7 +453,11 @@ SMTP 使用全局 `config.yaml` 的 `smtp` 段;支持 587 STARTTLS / 465 TLS
**201** → Rule;冲突 → **409**
#### `GET /api/v1/rules` / `GET /api/v1/rules/:id`
#### `GET /api/v1/rules` — 列表
Query`page``page_size`。**200** `{ "data": Rule[], "total", "page" }`
#### `GET /api/v1/rules/:id`
#### `PUT /api/v1/rules/:id` — 更新