* 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;
})
| 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 |
no test coverage detected