Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

Swap queue to pgBoss

x032205335012163514
diff --git a/backend/src/services/notification/notification-queue.ts b/backend/src/services/notification/notification-queue.ts
index 2d9f6dff5c..15f4b09ed3 100644
--- a/backend/src/services/notification/notification-queue.ts
+++ b/backend/src/services/notification/notification-queue.ts
@@ -1,4 +1,4 @@
-import { QueueJobs, QueueName, TQueueServiceFactory } from "@app/queue";
+import { QueueJobs, TQueueServiceFactory } from "@app/queue";
import { TCreateUserNotificationDTO } from "./notification-types";
import { TUserNotificationDALFactory } from "./user-notification-dal";
@@ -17,25 +17,28 @@ export const notificationQueueServiceFactory = async ({
queueService
}: TNotificationQueueServiceFactoryDep): Promise<TNotificationQueueServiceFactory> => {
const pushUserNotification = async (data: TCreateUserNotificationDTO) => {
- await queueService.queue<QueueName.UserNotification>(QueueName.UserNotification, QueueJobs.UserNotification, data, {
- removeOnFail: {
- count: 3
- },
- removeOnComplete: true
- });
+ await queueService.queuePg(QueueJobs.UserNotification, data);
};
- queueService.start(QueueName.UserNotification, async (job) => {
- const { userId, type, title, body, link } = job.data;
+ await queueService.startPg(
+ QueueJobs.UserNotification,
+ async ([job]) => {
+ const { userId, type, title, body, link } = job.data as TCreateUserNotificationDTO;
- await userNotificationDAL.create({
- userId,
- type,
- title,
- body,
- link
- });
- });
+ await userNotificationDAL.create({
+ userId,
+ type,
+ title,
+ body,
+ link
+ });
+ },
+ {
+ batchSize: 100,
+ workerCount: 5,
+ pollingIntervalSeconds: 2
+ }
+ );
return {
pushUserNotification