MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / add

Method add

packages/db/src/buffers/replay-buffer.ts:35–56  ·  view source on GitHub ↗
(chunk: IClickhouseSessionReplayChunk)

Source from the content-addressed store, hash-verified

33 }
34
35 async add(chunk: IClickhouseSessionReplayChunk) {
36 return this.timeAdd(async () => {
37 try {
38 const redis = getRedisCache();
39 const result = await redis
40 .multi()
41 .rpush(this.redisKey, JSON.stringify(chunk))
42 .llen(this.redisKey)
43 .exec();
44
45 const bufferLength = (result?.[1]?.[1] as number) ?? 0;
46 if (bufferLength >= this.batchSize) {
47 await this.tryFlush({ trigger: 'add' });
48 }
49 } catch (error) {
50 this.logger.error(
51 { err: error },
52 'Failed to add replay chunk to buffer'
53 );
54 }
55 });
56 }
57
58 protected getRedisListKey(): string {
59 return this.redisKey;

Callers

nothing calls this directly

Calls 5

getRedisCacheFunction · 0.90
timeAddMethod · 0.80
tryFlushMethod · 0.80
stringifyMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected