init redis lazy

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-07-20 20:17:32 +02:00
parent 492141547d
commit f2298a1b05
19 changed files with 134 additions and 86 deletions

View File

@@ -14,7 +14,7 @@ import type {
EventsQueuePayloadCreateSessionEnd,
EventsQueuePayloadIncomingEvent,
} from '@openpanel/queue';
import { redis } from '@openpanel/redis';
import { getRedisQueue } from '@openpanel/redis';
function noDateInFuture(eventDate: Date): Date {
if (eventDate > new Date()) {
@@ -217,7 +217,9 @@ async function getSessionEnd({
currentDeviceId: string;
previousDeviceId: string;
}) {
const sessionEndKeys = await redis.keys(`*:sessionEnd:${projectId}:*`);
const sessionEndKeys = await getRedisQueue().keys(
`*:sessionEnd:${projectId}:*`
);
const sessionEndJobCurrentDeviceId = await findJobByPrefix(
sessionsQueue,

View File

@@ -7,7 +7,6 @@ import type {
EventsQueuePayloadCreateSessionEnd,
EventsQueuePayloadIncomingEvent,
} from '@openpanel/queue';
import { redis } from '@openpanel/redis';
import { createSessionEnd } from './events.create-session-end';
import { incomingEvent } from './events.incoming-event';