mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-09 09:28:28 +00:00
Swap queue to pgBoss
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { QueueJobs, QueueName, TQueueServiceFactory } from "@app/queue";
|
import { QueueJobs, TQueueServiceFactory } from "@app/queue";
|
||||||
|
|
||||||
import { TCreateUserNotificationDTO } from "./notification-types";
|
import { TCreateUserNotificationDTO } from "./notification-types";
|
||||||
import { TUserNotificationDALFactory } from "./user-notification-dal";
|
import { TUserNotificationDALFactory } from "./user-notification-dal";
|
||||||
@@ -17,25 +17,28 @@ export const notificationQueueServiceFactory = async ({
|
|||||||
queueService
|
queueService
|
||||||
}: TNotificationQueueServiceFactoryDep): Promise<TNotificationQueueServiceFactory> => {
|
}: TNotificationQueueServiceFactoryDep): Promise<TNotificationQueueServiceFactory> => {
|
||||||
const pushUserNotification = async (data: TCreateUserNotificationDTO) => {
|
const pushUserNotification = async (data: TCreateUserNotificationDTO) => {
|
||||||
await queueService.queue<QueueName.UserNotification>(QueueName.UserNotification, QueueJobs.UserNotification, data, {
|
await queueService.queuePg(QueueJobs.UserNotification, data);
|
||||||
removeOnFail: {
|
|
||||||
count: 3
|
|
||||||
},
|
|
||||||
removeOnComplete: true
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
queueService.start(QueueName.UserNotification, async (job) => {
|
await queueService.startPg(
|
||||||
const { userId, type, title, body, link } = job.data;
|
QueueJobs.UserNotification,
|
||||||
|
async ([job]) => {
|
||||||
|
const { userId, type, title, body, link } = job.data as TCreateUserNotificationDTO;
|
||||||
|
|
||||||
await userNotificationDAL.create({
|
await userNotificationDAL.create({
|
||||||
userId,
|
userId,
|
||||||
type,
|
type,
|
||||||
title,
|
title,
|
||||||
body,
|
body,
|
||||||
link
|
link
|
||||||
});
|
});
|
||||||
});
|
},
|
||||||
|
{
|
||||||
|
batchSize: 100,
|
||||||
|
workerCount: 5,
|
||||||
|
pollingIntervalSeconds: 2
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
pushUserNotification
|
pushUserNotification
|
||||||
|
|||||||
Reference in New Issue
Block a user