a lot
This commit is contained in:
@@ -1,12 +1,24 @@
|
||||
import { Queue } from 'bullmq';
|
||||
|
||||
import type { BatchPayload } from '@mixan/types';
|
||||
import type { IServiceCreateEventPayload } from '@mixan/db';
|
||||
|
||||
import { connection } from './connection';
|
||||
|
||||
export interface EventsQueuePayload {
|
||||
projectId: string;
|
||||
payload: BatchPayload[];
|
||||
export interface EventsQueuePayloadCreateEvent {
|
||||
type: 'createEvent';
|
||||
payload: IServiceCreateEventPayload;
|
||||
}
|
||||
export interface EventsQueuePayloadCreateSessionEnd {
|
||||
type: 'createSessionEnd';
|
||||
payload: Pick<IServiceCreateEventPayload, 'profileId'>;
|
||||
}
|
||||
export type EventsQueuePayload =
|
||||
| EventsQueuePayloadCreateEvent
|
||||
| EventsQueuePayloadCreateSessionEnd;
|
||||
|
||||
export interface CronQueuePayload {
|
||||
type: 'salt';
|
||||
payload: undefined;
|
||||
}
|
||||
|
||||
export const eventsQueue = new Queue<EventsQueuePayload>('events', {
|
||||
@@ -15,3 +27,10 @@ export const eventsQueue = new Queue<EventsQueuePayload>('events', {
|
||||
removeOnComplete: 10,
|
||||
},
|
||||
});
|
||||
|
||||
export const cronQueue = new Queue<CronQueuePayload>('cron', {
|
||||
connection,
|
||||
defaultJobOptions: {
|
||||
removeOnComplete: 10,
|
||||
},
|
||||
});
|
||||
|
||||
8
packages/queue/src/utils.ts
Normal file
8
packages/queue/src/utils.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import type { Job } from 'bullmq';
|
||||
|
||||
export function findJobByPrefix<T>(
|
||||
jobs: Job<T, any, string>[],
|
||||
prefix: string
|
||||
) {
|
||||
return jobs.find((job) => job.opts.jobId?.startsWith(prefix));
|
||||
}
|
||||
Reference in New Issue
Block a user