move all logic in event.controller to worker (speed up request)

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-04-02 15:57:36 +02:00
parent aed62c59e4
commit a877c44324
12 changed files with 3145 additions and 359 deletions

View File

@@ -1,9 +1,29 @@
import { Queue } from 'bullmq';
import type { IServiceCreateEventPayload } from '@openpanel/db';
import type { PostEventPayload } from '@openpanel/sdk';
import { connection } from './connection';
export interface EventsQueuePayloadIncomingEvent {
type: 'incomingEvent';
payload: {
projectId: string;
event: PostEventPayload;
geo: {
country: string | undefined;
city: string | undefined;
region: string | undefined;
continent: string | undefined;
};
headers: {
origin: string | undefined;
ua: string | undefined;
};
currentDeviceId: string;
previousDeviceId: string;
};
}
export interface EventsQueuePayloadCreateEvent {
type: 'createEvent';
payload: Omit<IServiceCreateEventPayload, 'id'>;
@@ -14,7 +34,8 @@ export interface EventsQueuePayloadCreateSessionEnd {
}
export type EventsQueuePayload =
| EventsQueuePayloadCreateEvent
| EventsQueuePayloadCreateSessionEnd;
| EventsQueuePayloadCreateSessionEnd
| EventsQueuePayloadIncomingEvent;
export interface CronQueuePayload {
type: 'salt';