(chunk: IClickhouseSessionReplayChunk)
| 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; |
nothing calls this directly
no test coverage detected