Files
Edu/services/push-gateway
SpecialX 0a71b02e04
Some checks failed
CI / quality-ts (push) Failing after 48s
CI / quality-go (push) Failing after 4s
CI / quality-proto (push) Failing after 2s
CI / deploy (push) Has been skipped
fix: code compliance audit and fix across all services
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.
2026-07-09 17:28:27 +08:00
..

Push Gateway 推送网关服务

版本0.1P5 骨架) 端口8081

职责

实时推送基础设施服务Go 实现),管理 WebSocket 长连接。 接收 Msg 服务的推送请求,维护用户在线连接池,将消息实时投递到浏览器/移动端。

技术栈

  • Go 1.22 + Gin 1.10
  • gorilla/websocket 1.5
  • golang-jwt/jwt/v5JWT 鉴权)
  • zap结构化日志骨架

开发

go mod tidy
go run main.go   # :8081

API

方法 路径 说明
GET /healthz 健康检查
GET /ws?token=JWT WebSocket 升级端点JWT 鉴权)
POST /internal/push 内部推送 APIMsg 服务调用)

环境变量

变量 默认值 说明
PUSH_GATEWAY_PORT 8081 服务端口
JWT_SECRET p1-dev-secret-change-in-production JWT 密钥

WebSocket 心跳

客户端发送 ping 文本帧,服务端回复 pong