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

Method cleanup

packages/db/src/buffers/session-buffer.ts:182–207  ·  view source on GitHub ↗

* Remove a closed session from Redis. Atomically gated on `sessionId` via * Lua: if a different session now occupies the `(projectId, deviceId)` * slot (because a boundary already overwrote it with a new session), the * call is a no-op — the new session still needs its blob and sorted-set

({
    projectId,
    deviceId,
    sessionId,
    profileId,
  }: {
    projectId: string;
    deviceId: string;
    sessionId: string;
    profileId?: string | null;
  })

Source from the content-addressed store, hash-verified

180 * fails (worker crash, network partition).
181 */
182 async cleanup({
183 projectId,
184 deviceId,
185 sessionId,
186 profileId,
187 }: {
188 projectId: string;
189 deviceId: string;
190 sessionId: string;
191 profileId?: string | null;
192 }): Promise<void> {
193 const pointerKey =
194 profileId && profileId !== deviceId
195 ? profileIndexKey(projectId, profileId)
196 : '';
197
198 await this.redis.eval(
199 CLEANUP_LUA,
200 3,
201 sessionKey(projectId, deviceId),
202 wallclockSetKey(projectId),
203 pointerKey,
204 sessionId,
205 deviceId
206 );
207 }
208
209 /**
210 * Extend an in-flight session with a new event. Returns the updated

Callers 3

sessionVacuumCronJobFunction · 0.80
createSessionEndFunction · 0.80

Calls 3

profileIndexKeyFunction · 0.70
sessionKeyFunction · 0.70
wallclockSetKeyFunction · 0.70

Tested by

no test coverage detected