NestJS (6 services): implement @RequirePermission decorator with SetMetadata+Reflector, register APP_GUARD globally, fix as assertions to type guards, add explicit return types, fix import type for express, fix /metrics implicit any, replace native Error with ApplicationError, remove typeorm remnants, register LifecycleService. teacher-bff: add logger, ApplicationError, GlobalErrorFilter, forward real userId to downstream, log downstream failures, migrate health controller to shared/health. Go (2 services): interface to any, doc comments, CORS dev whitelist, JWT secret fail-fast, push-gateway internal API auth, metrics and readyz endpoints, remove dead code. Python (2 services): lifespan return type, dev_mode to bool, data-ana APIRouter, ai POST body model, ClickHouse async wrapping.
Push Gateway 推送网关服务
版本:0.1(P5 骨架) 端口:8081
职责
实时推送基础设施服务(Go 实现),管理 WebSocket 长连接。 接收 Msg 服务的推送请求,维护用户在线连接池,将消息实时投递到浏览器/移动端。
技术栈
- Go 1.22 + Gin 1.10
- gorilla/websocket 1.5
- golang-jwt/jwt/v5(JWT 鉴权)
- zap(结构化日志,骨架)
开发
go mod tidy
go run main.go # :8081
API
| 方法 | 路径 | 说明 |
|---|---|---|
| GET | /healthz | 健康检查 |
| GET | /ws?token=JWT | WebSocket 升级端点(JWT 鉴权) |
| POST | /internal/push | 内部推送 API(Msg 服务调用) |
环境变量
| 变量 | 默认值 | 说明 |
|---|---|---|
| PUSH_GATEWAY_PORT | 8081 | 服务端口 |
| JWT_SECRET | p1-dev-secret-change-in-production | JWT 密钥 |
WebSocket 心跳
客户端发送 ping 文本帧,服务端回复 pong。