refactor(redis): 移除心跳日志长度限制和相关配置

移除Redis集成中对心跳日志和console日志的长度限制功能,包括:
1. 删除heartbeatTtlSeconds和consoleMaxLen配置项
2. 移除相关trim操作和测试用例
3. 简化RedisIntegration类中相关方法

同时为heartbeat_events表添加write_ts_ms字段记录写入时间
This commit is contained in:
2026-01-22 14:06:02 +08:00
parent b90faf4aa4
commit 1a505bfa29
5 changed files with 13 additions and 59 deletions

View File

@@ -34,15 +34,12 @@ describe('RedisIntegration protocol', () => {
apiBaseUrl: 'http://127.0.0.1:3000',
});
const calls = { rPush: [], lTrim: [] };
const calls = { rPush: [] };
redis.client = {
isReady: true,
rPush: async (key, value) => {
calls.rPush.push({ key, value });
},
lTrim: async (key, start, stop) => {
calls.lTrim.push({ key, start, stop });
},
};
const before = Date.now();
@@ -56,9 +53,6 @@ describe('RedisIntegration protocol', () => {
assert.equal(payload.apiBaseUrl, 'http://127.0.0.1:3000');
assert.equal(typeof payload.lastActiveAt, 'number');
assert.ok(payload.lastActiveAt >= before && payload.lastActiveAt <= after);
assert.equal(calls.lTrim.length, 1);
assert.deepEqual(calls.lTrim[0], { key: '项目心跳', start: -2000, stop: -1 });
});
it('caches heartbeat when redis is not ready and flushes later', async () => {
@@ -68,16 +62,13 @@ describe('RedisIntegration protocol', () => {
apiBaseUrl: 'http://127.0.0.1:3000',
});
const calls = { rPush: [], lTrim: [] };
const calls = { rPush: [] };
redis.client = {
isReady: false,
connect: async () => {},
rPush: async (key, value) => {
calls.rPush.push({ key, value });
},
lTrim: async (key, start, stop) => {
calls.lTrim.push({ key, start, stop });
},
};
await redis.writeHeartbeat();
@@ -93,7 +84,6 @@ describe('RedisIntegration protocol', () => {
assert.equal(payload.projectName, 'BLS主机心跳日志');
assert.equal(payload.apiBaseUrl, 'http://127.0.0.1:3000');
assert.equal(typeof payload.lastActiveAt, 'number');
assert.equal(calls.lTrim.length, 1);
});
it('buffers console logs when redis is not ready', async () => {
@@ -103,16 +93,13 @@ describe('RedisIntegration protocol', () => {
apiBaseUrl: 'http://127.0.0.1:3000',
});
const calls = { rPush: [], lTrim: [] };
const calls = { rPush: [] };
redis.client = {
isReady: false,
connect: async () => {},
rPush: async (key, ...values) => {
calls.rPush.push({ key, values });
},
lTrim: async (key, start, stop) => {
calls.lTrim.push({ key, start, stop });
},
};
await redis.info('hello', { module: 'test' });