From 9d73768c2e1a273c99aae9f918a1295cbd479b04 Mon Sep 17 00:00:00 2001 From: paulpascal Date: Wed, 27 Nov 2024 10:29:19 +0000 Subject: [PATCH 1/3] fix: address feedback and fix noticed issued on move contact (#223) --- .gitignore | 1 + src/config/config-worker.ts | 6 ++ src/lib/queues.ts | 9 +-- src/liquid/place/move_form.html | 7 ++- src/worker/move-contact-worker.ts | 87 +++++++++++++++++++-------- test/integration/move-contact.spec.ts | 3 +- 6 files changed, 83 insertions(+), 30 deletions(-) diff --git a/.gitignore b/.gitignore index bb68e9a3..576fdaee 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ dist src/package.json .eslintcache .DS_Store +upload-docs* \ No newline at end of file diff --git a/src/config/config-worker.ts b/src/config/config-worker.ts index 693451e0..ae6ee3f9 100644 --- a/src/config/config-worker.ts +++ b/src/config/config-worker.ts @@ -12,6 +12,12 @@ export const WorkerConfig = { port: Number(environment.REDIS_PORT), }, moveContactQueue: 'MOVE_CONTACT_QUEUE', + defaultJobOptions: { + attempts: 3, // Max retries for a failed job + backoff: { + type: 'custom', + }, + } }; const assertRedisConfig = () => { diff --git a/src/lib/queues.ts b/src/lib/queues.ts index 2b68de2a..398495d4 100644 --- a/src/lib/queues.ts +++ b/src/lib/queues.ts @@ -1,5 +1,5 @@ import { v4 } from 'uuid'; -import { JobsOptions, Queue, ConnectionOptions } from 'bullmq'; +import { JobsOptions, Queue, ConnectionOptions, DefaultJobOptions } from 'bullmq'; import { WorkerConfig } from '../config/config-worker'; export interface IQueue { @@ -17,9 +17,9 @@ export class BullQueue implements IQueue { public readonly name: string; public readonly bullQueue: Queue; - constructor(queueName: string, connection: ConnectionOptions) { + constructor(queueName: string, connection: ConnectionOptions, defaultJobOptions?: DefaultJobOptions) { this.name = queueName; - this.bullQueue = new Queue(queueName, { connection }); + this.bullQueue = new Queue(queueName, { connection, defaultJobOptions }); } public async add(jobParams: JobParams): Promise { @@ -37,5 +37,6 @@ export class BullQueue implements IQueue { export const getMoveContactQueue = () => new BullQueue( WorkerConfig.moveContactQueue, - WorkerConfig.redisConnection + WorkerConfig.redisConnection, + WorkerConfig.defaultJobOptions ); diff --git a/src/liquid/place/move_form.html b/src/liquid/place/move_form.html index 2788ed5a..59fb15c5 100644 --- a/src/liquid/place/move_form.html +++ b/src/liquid/place/move_form.html @@ -54,7 +54,12 @@

To