feat(push-gateway): config 扩展 + kafka consumer + ws handler + nextstep 文档

This commit is contained in:
SpecialX
2026-07-14 16:03:17 +08:00
parent 5a88c8b45d
commit 9fd7c018c2
8 changed files with 630 additions and 36 deletions

View File

@@ -12,8 +12,8 @@
// 5. hub.NewHub (in-memory connection registry)
// 6. redisclient.New + SetHub + RebuildPresenceOnStartup (ISSUE-058)
// 7. redisclient.SubscribeAll (cross-instance Pub/Sub fanout)
// 8. kafkaconsumer.New + goroutine Run (edu.notification.requested)
// 9. ws.NewHandler (JWT RS256, X-Internal-Token, WebSocket upgrade)
// 8. kafkaconsumer.New + goroutine Run (edu.notify.notification.sent, ARB-013)
// 9. ws.NewHandler (JWT RS256, X-Internal-Key, WebSocket upgrade)
// 10. health.NewReadyzer (/readyz soft-failure probe)
// 11. gin router + http.Server
//
@@ -116,9 +116,9 @@ func main() {
}
}
// 7. Kafka consumer (edu.notification.requested). Started only when at
// least one broker is configured; otherwise the HTTP /internal/push API
// is the only delivery channel.
// 7. Kafka consumer (edu.notify.notification.sent, ARB-013). Started only
// when at least one broker is configured; otherwise the HTTP /internal/push
// API is the only delivery channel.
var kafkaConsumer *kafkaconsumer.Consumer
var kafkaCancel context.CancelFunc
if len(cfg.KafkaBrokers) > 0 && cfg.KafkaNotificationTopic != "" {
@@ -161,7 +161,7 @@ func main() {
r.GET("/metrics", gin.WrapH(promhttp.Handler()))
// WebSocket upgrade (JWT auth via query ?token= or Authorization header).
r.GET("/ws", wsHandler.HandleWebSocket)
// Internal HTTP APIs consumed by msg (X-Internal-Token auth).
// Internal HTTP APIs consumed by msg (X-Internal-Key auth, ARB-013).
internal := r.Group("/internal")
internal.POST("/push", wsHandler.PushHandler)
internal.POST("/broadcast", wsHandler.BroadcastHandler)