feat(chat): implement sequence pre-allocation, versioned sync, and push worker
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:
23
internal/dto/sync_dto.go
Normal file
23
internal/dto/sync_dto.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package dto
|
||||
|
||||
// SyncVersionRequest 增量同步请求
|
||||
type SyncVersionRequest struct {
|
||||
Version int64 `form:"version" binding:"min=0"` // 客户端上次同步版本号,0 表示全量同步
|
||||
}
|
||||
|
||||
// SyncVersionResponse 增量同步响应
|
||||
type SyncVersionResponse struct {
|
||||
CurrentVersion int64 `json:"current_version"` // 服务端当前最大版本号
|
||||
Changes []SyncChangeItem `json:"changes"` // 变更列表
|
||||
FullSync bool `json:"full_sync"` // 是否需要全量同步(版本差距过大时)
|
||||
HasMore bool `json:"has_more"` // 是否还有更多变更
|
||||
}
|
||||
|
||||
// SyncChangeItem 单条变更项
|
||||
type SyncChangeItem struct {
|
||||
ConversationID string `json:"conversation_id"`
|
||||
ChangeType string `json:"change_type"` // new_msg, read, pin, unpin, mute, unmute, hide, group_update
|
||||
MaxSeq int64 `json:"max_seq,omitempty"`
|
||||
LastMessageAt int64 `json:"last_message_at,omitempty"`
|
||||
Version int64 `json:"version"`
|
||||
}
|
||||
Reference in New Issue
Block a user