Files
stats/packages/queue/src/queues.ts
Carl-Gerhard Lindesvärd 9c92803c4c a looooot
2024-02-22 21:50:30 +01:00

37 lines
867 B
TypeScript

import { Queue } from 'bullmq';
import type { IServiceCreateEventPayload } from '@mixan/db';
import { connection } from './connection';
export interface EventsQueuePayloadCreateEvent {
type: 'createEvent';
payload: Omit<IServiceCreateEventPayload, 'id'>;
}
export interface EventsQueuePayloadCreateSessionEnd {
type: 'createSessionEnd';
payload: Pick<IServiceCreateEventPayload, 'deviceId'>;
}
export type EventsQueuePayload =
| EventsQueuePayloadCreateEvent
| EventsQueuePayloadCreateSessionEnd;
export interface CronQueuePayload {
type: 'salt';
payload: undefined;
}
export const eventsQueue = new Queue<EventsQueuePayload>('events', {
connection,
defaultJobOptions: {
removeOnComplete: 10,
},
});
export const cronQueue = new Queue<CronQueuePayload>('cron', {
connection,
defaultJobOptions: {
removeOnComplete: 10,
},
});