feat(processor): 增加数据库连接断开检测与自动恢复机制

- 在 DatabaseManager 中添加 checkConnection 方法用于检测数据库连接状态
- 当数据库连接断开时,自动暂停 Kafka 消费者,防止消息堆积
- 实现每分钟数据库连接检查,连接恢复后自动恢复消费者处理
- 区分数据库连接错误和其他严重错误,连接错误时保留数据等待重试
- 在 .gitignore 中添加 SQL 文件排除
This commit is contained in:
2026-02-06 13:37:46 +08:00
parent d10bedb7e7
commit b72cdde8bf
5 changed files with 124 additions and 16 deletions

View File

@@ -48,6 +48,16 @@ class WebBLSHeartbeatServer {
this.heartbeatProcessor = new HeartbeatProcessor(this.config.processor, this.databaseManager, {
redis: this.redis,
stats: this.stats,
onDbOffline: () => {
if (this.consumers) {
this.consumers.forEach(c => c.consumer.pause());
}
},
onDbOnline: () => {
if (this.consumers) {
this.consumers.forEach(c => c.consumer.resume());
}
}
});
// 在单进程内启动 N 个消费者实例(与分区数匹配)