test(buffer): testing new buffer (only inserts, no processing)

This commit is contained in:
Carl-Gerhard Lindesvärd
2025-01-31 00:09:25 +00:00
parent 71bf22af51
commit a2b74a9b4d
5 changed files with 95 additions and 104 deletions

View File

@@ -1,13 +1,23 @@
import { TABLE_NAMES, ch } from '../clickhouse-client';
import type { IClickhouseBotEvent } from '../services/event.service';
import { BotBuffer as NewBotBuffer } from './bot-buffer-psql';
import { RedisBuffer } from './buffer';
const testNewBotBuffer = new NewBotBuffer();
type BufferType = IClickhouseBotEvent;
export class BotBuffer extends RedisBuffer<BufferType> {
constructor() {
super('events_bots', 500);
}
async add(event: BufferType) {
await super.add(event);
if (process.env.TEST_NEW_BUFFER) {
await testNewBotBuffer.add(event);
}
}
protected async insertIntoDB(items: BufferType[]): Promise<void> {
await ch.insert({
table: TABLE_NAMES.events_bots,