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

@@ -34,6 +34,9 @@ type Config struct {
SetupSecret string `mapstructure:"setup_secret"`
WebSocket WSConfig `mapstructure:"websocket"`
Runner RunnerConfig `mapstructure:"runner"`
SeqBuffer SeqBufferConfig `mapstructure:"seq_buffer"`
VersionLog VersionLogConfig `mapstructure:"version_log"`
PushWorker PushWorkerConfig `mapstructure:"push_worker"`
}
// Load 加载配置文件
@@ -191,6 +194,25 @@ func Load(configPath string) (*Config, error) {
viper.SetDefault("runner.cluster.cap_prefix", "runner:cap:")
viper.SetDefault("runner.cluster.registry_ttl", 90)
viper.SetDefault("runner.cluster.heartbeat_interval", 30)
// SeqBuffer 默认值
viper.SetDefault("seq_buffer.enabled", false)
viper.SetDefault("seq_buffer.private_buffer_size", 50)
viper.SetDefault("seq_buffer.group_buffer_size", 200)
viper.SetDefault("seq_buffer.lock_timeout_ms", 5000)
viper.SetDefault("seq_buffer.max_retries", 3)
// VersionLog 默认值
viper.SetDefault("version_log.enabled", false)
viper.SetDefault("version_log.sync_limit", 100)
viper.SetDefault("version_log.max_sync_gap", 1000)
// PushWorker 默认值
viper.SetDefault("push_worker.enabled", false)
viper.SetDefault("push_worker.stream", "msg_push")
viper.SetDefault("push_worker.group", "push_worker")
viper.SetDefault("push_worker.batch_size", 50)
viper.SetDefault("push_worker.poll_timeout_ms", 2000)
viper.SetDefault("push_worker.max_retries", 3)
viper.SetDefault("push_worker.max_stream_len", 100000)
viper.SetDefault("push_worker.idle_timeout_ms", 30000)
if err := viper.ReadInConfig(); err != nil {
return nil, fmt.Errorf("failed to read config: %w", err)