From f9629f13870b7fad7a5df01225060fe7dcdabf3d Mon Sep 17 00:00:00 2001 From: Olivier Louvignes Date: Fri, 5 Jul 2024 18:57:10 +0200 Subject: [PATCH] feat(update): minor changes --- src/PrismaQueue.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/PrismaQueue.ts b/src/PrismaQueue.ts index 9b1ff57..e88b9ed 100644 --- a/src/PrismaQueue.ts +++ b/src/PrismaQueue.ts @@ -18,6 +18,7 @@ import { export type PrismaQueueOptions = { prisma?: PrismaClient; name?: string; + maxAttempts?: number | null; maxConcurrency?: number; pollInterval?: number; jobInterval?: number; @@ -89,6 +90,7 @@ export class PrismaQueue< name = "default", modelName = "QueueJob", tableName = getTableName(modelName), + maxAttempts = null, maxConcurrency = DEFAULT_MAX_CONCURRENCY, pollInterval = DEFAULT_POLL_INTERVAL, jobInterval = DEFAULT_JOB_INTERVAL, @@ -105,6 +107,7 @@ export class PrismaQueue< this.config = { modelName, tableName, + maxAttempts, maxConcurrency, pollInterval, jobInterval, @@ -172,8 +175,8 @@ export class PrismaQueue< options: EnqueueOptions = {}, ): Promise> { debug(`enqueue`, this.name, payloadOrFunction, options); - const { name: queueName } = this; - const { key, cron = null, maxAttempts = null, priority = 0, runAt } = options; + const { name: queueName, config } = this; + const { key, cron = null, maxAttempts = config.maxAttempts, priority = 0, runAt } = options; const record = await this.#prisma.$transaction(async (client) => { const payload = payloadOrFunction instanceof Function ? await payloadOrFunction(client) : payloadOrFunction;