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

@@ -17,17 +17,26 @@ import type {
} from '../services/profile.service';
import type { Find, FindMany } from './buffer';
import { RedisBuffer } from './buffer';
import { ProfileBuffer as NewProfileBuffer } from './profile-buffer-psql';
const BATCH_SIZE = process.env.BATCH_SIZE_PROFILES
? Number.parseInt(process.env.BATCH_SIZE_PROFILES, 10)
: 50;
const testNewProfileBuffer = new NewProfileBuffer();
type BufferType = IClickhouseProfile;
export class ProfileBuffer extends RedisBuffer<BufferType> {
constructor() {
super('profiles', BATCH_SIZE);
}
async add(profile: BufferType) {
await super.add(profile);
if (process.env.TEST_NEW_BUFFER) {
await testNewProfileBuffer.add(profile);
}
}
// this will do a couple of things:
// - we slice the queue to maxBufferSize since this queries have a limit on character count
// - check redis cache for profiles