Files
Edu/services/push-gateway
SpecialX d8dab70406
Some checks failed
CI / quality-proto (push) Failing after 2s
CI / deploy (push) Has been skipped
CI / quality-ts (push) Failing after 1m11s
CI / quality-go (push) Failing after 5s
feat(infra): add OTel auto-instrumentations across all services
NestJS 6 services use getNodeAutoInstrumentations().

Python 2 services use FastAPIInstrumentor. Go 2 services use otelgin.
2026-07-09 13:25:46 +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