diff --git a/packages/api/src/queueAdapters/base.ts b/packages/api/src/queueAdapters/base.ts index c4a652bd..f2747dc6 100644 --- a/packages/api/src/queueAdapters/base.ts +++ b/packages/api/src/queueAdapters/base.ts @@ -8,10 +8,12 @@ import { export abstract class BaseAdapter { public readonly readOnlyMode: boolean; + public readonly prefix: string; private formatters: Record any> = {}; protected constructor(options: Partial = {}) { this.readOnlyMode = options.readOnlyMode === true; + this.prefix = options.prefix || ''; } public setFormatter(field: 'data' | 'returnValue', formatter: (data: any) => any): void { diff --git a/packages/api/src/queueAdapters/bull.ts b/packages/api/src/queueAdapters/bull.ts index bc260fe3..0f757e43 100644 --- a/packages/api/src/queueAdapters/bull.ts +++ b/packages/api/src/queueAdapters/bull.ts @@ -1,10 +1,5 @@ import { Job, Queue } from 'bull'; -import { - JobCleanStatus, - JobCounts, - JobStatus, - QueueAdapterOptions, -} from '../../typings/app'; +import { JobCleanStatus, JobCounts, JobStatus, QueueAdapterOptions } from '../../typings/app'; import { BaseAdapter } from './base'; export class BullAdapter extends BaseAdapter { @@ -17,7 +12,7 @@ export class BullAdapter extends BaseAdapter { } public getName(): string { - return this.queue.name; + return `${this.prefix}${this.queue.name}`; } public clean(jobStatus: JobCleanStatus, graceTimeMs: number): Promise { @@ -28,17 +23,13 @@ export class BullAdapter extends BaseAdapter { return this.queue.getJob(id); } - public getJobs( - jobStatuses: JobStatus[], - start?: number, - end?: number - ): Promise { + public getJobs(jobStatuses: JobStatus[], start?: number, end?: number): Promise { return this.queue.getJobs(jobStatuses as any, start, end); } // eslint-disable-next-line @typescript-eslint/no-unused-vars public getJobCounts(..._jobStatuses: JobStatus[]): Promise { - return (this.queue.getJobCounts() as unknown) as Promise; + return this.queue.getJobCounts() as unknown as Promise; } public getJobLogs(id: string): Promise { diff --git a/packages/api/src/queueAdapters/bullMQ.ts b/packages/api/src/queueAdapters/bullMQ.ts index c5adbd88..090054c9 100644 --- a/packages/api/src/queueAdapters/bullMQ.ts +++ b/packages/api/src/queueAdapters/bullMQ.ts @@ -15,7 +15,7 @@ export class BullMQAdapter extends BaseAdapter { } public getName(): string { - return this.queue.name; + return `${this.prefix}${this.queue.name}`; } public clean(jobStatus: JobCleanStatus, graceTimeMs: number): Promise { diff --git a/packages/api/typings/app.ts b/packages/api/typings/app.ts index d4dd2c4e..1443c549 100644 --- a/packages/api/typings/app.ts +++ b/packages/api/typings/app.ts @@ -11,6 +11,7 @@ export type JobCounts = Record; export interface QueueAdapterOptions { readOnlyMode: boolean; + prefix: string; } export type BullBoardQueues = Map;