From cc7b93a5430c387e31c40fd1cc132cad654a607b Mon Sep 17 00:00:00 2001 From: Zac Clifton Date: Wed, 20 Sep 2023 15:00:17 -0400 Subject: [PATCH 1/2] add inbound queue to metrics --- .../services/inbound-parse.queue.service.ts | 2 +- apps/inbound-mail/src/server/inbound-mail.service.ts | 10 +++------- .../application-generic/src/custom-providers/index.ts | 8 ++++++-- .../src/health/inbound-parse-queue.health-indicator.ts | 6 +++--- .../application-generic/src/modules/queues.module.ts | 6 +++--- .../application-generic/src/services/queues/index.ts | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/apps/api/src/app/inbound-parse/services/inbound-parse.queue.service.ts b/apps/api/src/app/inbound-parse/services/inbound-parse.queue.service.ts index 208ede0aff3..99a29e38c15 100644 --- a/apps/api/src/app/inbound-parse/services/inbound-parse.queue.service.ts +++ b/apps/api/src/app/inbound-parse/services/inbound-parse.queue.service.ts @@ -1,6 +1,6 @@ import { getInboundParseMailWorkerOptions, - InboundParseQueue, + InboundParseQueueService as InboundParseQueue, InboundParseWorker, Queue, QueueOptions, diff --git a/apps/inbound-mail/src/server/inbound-mail.service.ts b/apps/inbound-mail/src/server/inbound-mail.service.ts index c9c6911b96a..00dba59d02d 100644 --- a/apps/inbound-mail/src/server/inbound-mail.service.ts +++ b/apps/inbound-mail/src/server/inbound-mail.service.ts @@ -1,14 +1,10 @@ -import { BullMqService, InboundParseQueue, QueueBaseOptions } from '@novu/application-generic'; +import { BullMqService, InboundParseQueueService, QueueBaseOptions } from '@novu/application-generic'; import { JobTopicNameEnum } from '@novu/shared'; export class InboundMailService { - private inboundParseQueue: InboundParseQueue; + public inboundParseQueueService: InboundParseQueueService; constructor() { - this.inboundParseQueue = new InboundParseQueue(); - } - - public get inboundParseQueueService() { - return this.inboundParseQueue; + this.inboundParseQueueService = new InboundParseQueueService(); } } diff --git a/packages/application-generic/src/custom-providers/index.ts b/packages/application-generic/src/custom-providers/index.ts index 6b736881e17..0593e21480b 100644 --- a/packages/application-generic/src/custom-providers/index.ts +++ b/packages/application-generic/src/custom-providers/index.ts @@ -4,13 +4,14 @@ import { CacheInMemoryProviderService, CacheService, DistributedLockService, + ExecutionLogQueueService, FeatureFlagsService, + InboundParseQueueService, ReadinessService, StandardQueueService, SubscriberProcessQueueService, WebSocketsQueueService, WorkflowQueueService, - ExecutionLogQueueService, } from '../services'; import { GetIsApiRateLimitingEnabled, @@ -129,7 +130,8 @@ export const bullMqTokenList = { webSocketsQueueService: WebSocketsQueueService, workflowQueueService: WorkflowQueueService, subscriberProcessQueueService: SubscriberProcessQueueService, - executionLogQueueService: ExecutionLogQueueService + executionLogQueueService: ExecutionLogQueueService, + inboundParseQueueService: InboundParseQueueService ) => { return [ standardQueueService, @@ -137,6 +139,7 @@ export const bullMqTokenList = { workflowQueueService, subscriberProcessQueueService, executionLogQueueService, + inboundParseQueueService, ]; }, inject: [ @@ -145,5 +148,6 @@ export const bullMqTokenList = { WorkflowQueueService, SubscriberProcessQueueService, ExecutionLogQueueService, + InboundParseQueueService, ], }; diff --git a/packages/application-generic/src/health/inbound-parse-queue.health-indicator.ts b/packages/application-generic/src/health/inbound-parse-queue.health-indicator.ts index c73f651add2..aa762d9b9df 100644 --- a/packages/application-generic/src/health/inbound-parse-queue.health-indicator.ts +++ b/packages/application-generic/src/health/inbound-parse-queue.health-indicator.ts @@ -1,15 +1,15 @@ import { Injectable } from '@nestjs/common'; -import { InboundParseQueue } from '../services/queues'; +import { InboundParseQueueService } from '../services/queues'; import { QueueHealthIndicator } from './queue-health-indicator.service'; const LOG_CONTEXT = 'InboundParseQueueServiceHealthIndicator'; -const INDICATOR_KEY = 'inboundParseQueue'; +const INDICATOR_KEY = 'inboundParseQueueService'; const SERVICE_NAME = 'InboundParseQueueService'; @Injectable() export class InboundParseQueueServiceHealthIndicator extends QueueHealthIndicator { - constructor(private inboundParseQueueService: InboundParseQueue) { + constructor(private inboundParseQueueService: InboundParseQueueService) { super(inboundParseQueueService, INDICATOR_KEY, SERVICE_NAME, LOG_CONTEXT); } } diff --git a/packages/application-generic/src/modules/queues.module.ts b/packages/application-generic/src/modules/queues.module.ts index 86ed8e7d489..38ef0f38638 100644 --- a/packages/application-generic/src/modules/queues.module.ts +++ b/packages/application-generic/src/modules/queues.module.ts @@ -15,7 +15,7 @@ import { ActiveJobsMetricQueueService, CompletedJobsMetricQueueService, ExecutionLogQueueService, - InboundParseQueue, + InboundParseQueueService, StandardQueueService, SubscriberProcessQueueService, WebSocketsQueueService, @@ -39,7 +39,7 @@ const PROVIDERS: Provider[] = [ CompletedJobsMetricQueueService, CompletedJobsMetricQueueServiceHealthIndicator, CompletedJobsMetricWorkerService, - InboundParseQueue, + InboundParseQueueService, InboundParseWorker, InboundParseQueueServiceHealthIndicator, ReadinessService, @@ -65,7 +65,7 @@ const PROVIDERS: Provider[] = [ export class QueuesModule {} const APP_PROVIDERS: Provider[] = [ - InboundParseQueue, + InboundParseQueueService, InboundParseWorker, InboundParseQueueServiceHealthIndicator, WebSocketsQueueService, diff --git a/packages/application-generic/src/services/queues/index.ts b/packages/application-generic/src/services/queues/index.ts index 7451b9ef901..276ac42b137 100644 --- a/packages/application-generic/src/services/queues/index.ts +++ b/packages/application-generic/src/services/queues/index.ts @@ -13,7 +13,7 @@ export { QueueBaseService, ActiveJobsMetricQueueService, CompletedJobsMetricQueueService, - InboundParseQueueService as InboundParseQueue, + InboundParseQueueService, StandardQueueService, WebSocketsQueueService, WorkflowQueueService, From d1edbf9e12ce48bfd3cde389e225a0efaff5c7c5 Mon Sep 17 00:00:00 2001 From: p-fernandez Date: Tue, 28 Nov 2023 11:34:31 +0000 Subject: [PATCH 2/2] fix(inbound): fix test --- apps/inbound-mail/src/server/inbound-mail.service.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/inbound-mail/src/server/inbound-mail.service.spec.ts b/apps/inbound-mail/src/server/inbound-mail.service.spec.ts index f0e1a674848..dbe2b925e00 100644 --- a/apps/inbound-mail/src/server/inbound-mail.service.spec.ts +++ b/apps/inbound-mail/src/server/inbound-mail.service.spec.ts @@ -24,7 +24,7 @@ describe('Inbound Mail Service', () => { it('should be initialised properly', async () => { expect(inboundMailService).to.be.ok; - expect(inboundMailService).to.have.all.keys('inboundParseQueue'); + expect(inboundMailService).to.have.all.keys('inboundParseQueueService'); expect(inboundMailService.inboundParseQueueService.DEFAULT_ATTEMPTS).to.equal(3); expect(inboundMailService.inboundParseQueueService.topic).to.equal('inbound-parse-mail'); expect(await inboundMailService.inboundParseQueueService.bullMqService.getStatus()).to.deep.equal({