feat(websocket): integrate WebSocket support and refactor SSE handling
All checks were successful
Build Backend / build (push) Successful in 18m57s
Build Backend / build-docker (push) Successful in 1m4s

- Added WebSocket support by introducing a new WSHandler and related infrastructure.
- Replaced SSE implementations with WebSocket equivalents across message and QR code handlers.
- Updated service and repository layers to utilize WebSocket for real-time messaging.
- Removed obsolete SSE hub and related code, streamlining the application for WebSocket usage.
- Enhanced router to include WebSocket endpoints for real-time communication.
This commit is contained in:
lafay
2026-03-26 21:17:49 +08:00
parent c6848aba06
commit 6d335e393d
19 changed files with 1277 additions and 315 deletions

View File

@@ -12,7 +12,7 @@ import (
"carrot_bbs/internal/pkg/openai"
"carrot_bbs/internal/pkg/redis"
"carrot_bbs/internal/pkg/s3"
"carrot_bbs/internal/pkg/sse"
"carrot_bbs/internal/pkg/ws"
"carrot_bbs/internal/repository"
"carrot_bbs/internal/service"
@@ -44,8 +44,8 @@ var InfrastructureSet = wire.NewSet(
ProvideBuiltinHooks,
ProvideModerationHooks,
// SSE Hub
ProvideSSEHub,
// WebSocket Hub
ProvideWSHub,
// 外部服务客户端
ProvideOpenAIClient,
@@ -156,9 +156,9 @@ func ProvideModerationHooks(
return moderationHooks
}
// ProvideSSEHub 提供 SSE Hub
func ProvideSSEHub() *sse.Hub {
return sse.NewHub()
// ProvideWSHub 提供 WebSocket Hub
func ProvideWSHub() *ws.Hub {
return ws.NewHub()
}
// ProvideOpenAIClient 提供 OpenAI 客户端