M0-02 Event Bus & Reliability 基础版 #2

Closed
opened 2026-05-22 21:00:15 +08:00 by wangdl · 2 comments
Owner

实施状态 — 全部完成

模块 说明
BullMQ 基础设施 4 个队列:ai-analysis, document-import, notification, domain-events
EventBusService publish() 同步 + publishAsync() 异步
BaseDomainEvent eventId/occurredAt/eventType
Admin Events AAPI GET/POST /admin-api/events 队列管理
Admin Web 页面 admin.longde.cloud → 系统运维 → 事件队列

Admin AAPI

端点 说明
GET /admin-api/events 所有队列统计
GET /admin-api/events/:queue/failed 失败任务列表
GET /admin-api/events/:queue/jobs/:id 任务详情
POST /admin-api/events/:queue/jobs/:id/retry 手动重试

Admin Web

页面 路径 说明
事件队列 /events 队列概览表格 + 失败任务列表 + 重试按钮
入口 侧边栏 → 系统运维 → 事件队列 SUPER_ADMIN only

交付检查

  • EventBusService
  • 同步事件 EventEmitter2
  • 异步事件 BullMQ
  • 事件持久化
  • 重试策略
  • 死信队列
  • 幂等键
  • Admin AAPI
  • Admin Web 页面
  • 日志脱敏
## 实施状态 — ✅ 全部完成 | 模块 | 说明 | |------|------| | BullMQ 基础设施 | 4 个队列:ai-analysis, document-import, notification, domain-events | | EventBusService | publish() 同步 + publishAsync() 异步 | | BaseDomainEvent | eventId/occurredAt/eventType | | Admin Events AAPI | GET/POST /admin-api/events 队列管理 | | Admin Web 页面 | admin.longde.cloud → 系统运维 → 事件队列 | ### Admin AAPI | 端点 | 说明 | |------|------| | GET /admin-api/events | 所有队列统计 | | GET /admin-api/events/:queue/failed | 失败任务列表 | | GET /admin-api/events/:queue/jobs/:id | 任务详情 | | POST /admin-api/events/:queue/jobs/:id/retry | 手动重试 | ### Admin Web | 页面 | 路径 | 说明 | |------|------|------| | 事件队列 | /events | 队列概览表格 + 失败任务列表 + 重试按钮 | | 入口 | 侧边栏 → 系统运维 → 事件队列 | SUPER_ADMIN only | ### 交付检查 - [x] EventBusService - [x] 同步事件 EventEmitter2 - [x] 异步事件 BullMQ - [x] 事件持久化 - [x] 重试策略 - [x] 死信队列 - [x] 幂等键 - [x] Admin AAPI - [x] Admin Web 页面 - [x] 日志脱敏
wangdl added this to the M0:后端基础能力与架构规范闭环(P0) milestone 2026-05-22 21:00:15 +08:00
wangdl self-assigned this 2026-05-22 21:00:15 +08:00
Author
Owner

E2E 测试通过

M0 E2E 测试已全部通过 — 28/28 tests passed,耗时 ~1.4s。

本 Issue 测试内容

GET /admin-api/events → 200 queue overview, 401 without token, failed jobs endpoint

运行方式

npm run test:e2e

测试架构

  • Mock 层: @prisma/client / ioredis / jose / @nestjs/bullmq
  • 无需本地 MySQL/Redis,纯 mock 轻量集成测试
  • 测试文件: test/m0.e2e-spec.ts
## ✅ E2E 测试通过 M0 E2E 测试已全部通过 — **28/28 tests passed**,耗时 ~1.4s。 ### 本 Issue 测试内容 GET /admin-api/events → 200 queue overview, 401 without token, failed jobs endpoint ### 运行方式 ```bash npm run test:e2e ``` ### 测试架构 - Mock 层: `@prisma/client` / `ioredis` / `jose` / `@nestjs/bullmq` - 无需本地 MySQL/Redis,纯 mock 轻量集成测试 - 测试文件: `test/m0.e2e-spec.ts`
Author
Owner

关闭

M0 基础设施已实现并被后续 M1-M7 具体 issue 覆盖。相关代码已在生产运行。

## 关闭 M0 基础设施已实现并被后续 M1-M7 具体 issue 覆盖。相关代码已在生产运行。
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: wangdl/api-server#2
No description provided.