feat(chat): implement sequence pre-allocation, versioned sync, and push worker
All checks were successful
Build Backend / build (push) Successful in 4m20s
Build Backend / build-docker (push) Successful in 1m7s

Introduce several performance and synchronization enhancements:
- Implement `SeqBufferManager` to allow sequence number pre-allocation via Redis Lua scripts, reducing atomic increment overhead.
- Add `PushWorker` to handle asynchronous message pushing using Redis Streams.
- Implement incremental conversation synchronization via `ConversationVersionLog` to allow clients to fetch only recent changes.
- Add support for Gzip compression in WebSocket communications to reduce bandwidth usage.
- Update dependency injection and configuration to support these new components.
This commit is contained in:
2026-05-17 23:38:04 +08:00
parent f63c795dcb
commit 6bf87fec46
26 changed files with 1450 additions and 82 deletions

View File

@@ -312,3 +312,24 @@ websocket:
msg_channel: "ws:msg" # Redis Pub/Sub 频道
online_ttl: 60 # 在线状态 TTL
heartbeat_interval: 20 # 心跳间隔(秒)
# Seq 预分配配置
# 环境变量:
# APP_SEQ_BUFFER_ENABLED, APP_SEQ_BUFFER_PRIVATE_BUFFER_SIZE
# APP_SEQ_BUFFER_GROUP_BUFFER_SIZE, APP_SEQ_BUFFER_LOCK_TIMEOUT_MS
# APP_SEQ_BUFFER_MAX_RETRIES
seq_buffer:
enabled: false # 启用后使用 Lua 预分配代替 INCR关闭则回退旧逻辑
private_buffer_size: 50 # 私聊每次向 Redis 预分配步长
group_buffer_size: 200 # 群聊每次向 Redis 预分配步长(群聊消息更频繁)
lock_timeout_ms: 5000 # 分布式锁超时(毫秒)
max_retries: 3 # 冷启动获取锁失败最大重试次数
# 版本日志增量同步配置
# 环境变量:
# APP_VERSION_LOG_ENABLED, APP_VERSION_LOG_SYNC_LIMIT
# APP_VERSION_LOG_MAX_SYNC_GAP
version_log:
enabled: false # 启用后客户端可使用 /conversations/sync 增量同步
sync_limit: 100 # 单次同步最大返回变更条数
max_sync_gap: 1000 # 版本差距超过此值建议全量同步