feat: 新增 G4 热表独立双写能力
- 新增配置项以支持旧/新明细表的独立写入开关及目标表名。 - 重构 DatabaseManager,抽象通用批量 COPY 写入内核,支持不同目标表的复用。 - 新增双明细写入编排器,支持旧/新表独立执行、重试及 fallback。 - 调整 HeartbeatProcessor.processBatch(),确保 room_status 独立执行。 - 错误表仅记录新表写入失败,旧表失败不再写入错误表。 - 重新定义消费暂停策略,基于当前启用的关键 sink 判断。 - 补充按 sink 维度的统计项与启动日志。 新增 G4 热表相关的数据库规范与处理逻辑,确保系统在双写模式下的稳定性与可扩展性。
This commit is contained in:
@@ -90,10 +90,15 @@ describe('HeartbeatProcessor arrays', () => {
|
||||
it('end-to-end: message buffer -> processMessage -> insertHeartbeatEvents payload includes arrays', async () => {
|
||||
let captured = null;
|
||||
const db = {
|
||||
insertHeartbeatEvents: async (events) => {
|
||||
config: { legacyHeartbeatEnabled: true, g4HotHeartbeatEnabled: false, roomStatusEnabled: false, legacyTable: 'heartbeat.heartbeat_events' },
|
||||
insertHeartbeatEventsDual: async (events) => {
|
||||
captured = events;
|
||||
return { insertedCount: events.length };
|
||||
return {
|
||||
legacy: { enabled: true, success: true, insertedCount: events.length, failedRecords: [], error: null, isConnectionError: false, batchError: null },
|
||||
g4Hot: { enabled: false, success: true, insertedCount: 0, failedRecords: [], error: null, isConnectionError: false, batchError: null },
|
||||
};
|
||||
},
|
||||
insertHeartbeatEvents: async (events) => ({ insertedCount: events.length }),
|
||||
};
|
||||
|
||||
const processor = new HeartbeatProcessor({ batchSize: 1, batchTimeout: 1000 }, db);
|
||||
|
||||
Reference in New Issue
Block a user