From 01975079e3e77dfa123324d4c810801066702d8f Mon Sep 17 00:00:00 2001 From: Rishi Ghan Date: Tue, 22 Aug 2023 05:20:24 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=82=20Queue=20drain=20event?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/jobqueue.service.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/services/jobqueue.service.ts b/services/jobqueue.service.ts index 1df1381..947c2e7 100644 --- a/services/jobqueue.service.ts +++ b/services/jobqueue.service.ts @@ -168,7 +168,17 @@ export default class JobQueueService extends Service { async "enqueue.async.active"(ctx: Context<{ id: Number }>) { console.log(`Job ID ${ctx.params.id} is set to active.`); }, - + async "drained"(ctx) { + console.log("Queue drained."); + this.broker.call("socket.broadcast", { + namespace: "/", + event: "action", + args: [{ + type: "LS_IMPORT_QUEUE_DRAINED", + data: "cham" + }], + }); + }, async "enqueue.async.completed"(ctx: Context<{ id: Number }>) { // 1. Fetch the job result using the job Id const job = await this.job(ctx.params.id); @@ -197,10 +207,6 @@ export default class JobQueueService extends Service { // 6. Purge it from Redis await job.remove(); - // 7. Check - const jobCounts = this.getJobCounts("active", "completed", "failed"); - console.log("ASDASD"); - console.log(jobCounts); console.log(`Job ID ${ctx.params.id} completed.`); },