35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
import type { EnvRecord } from "@hivegrid/config";
|
|
import { getQueueNamesForGroup, isWorkerQueueGroup, queueNames, type QueueName } from "@hivegrid/queue";
|
|
|
|
export const defaultWorkerQueueNames = [queueNames.email, queueNames.notifications] as const satisfies readonly QueueName[];
|
|
|
|
export function getWorkerQueueNames(
|
|
env: EnvRecord & {
|
|
EXPORT_RETENTION_QUEUE_ENABLED?: string;
|
|
IMPORT_QUEUE_ENABLED?: string;
|
|
IMPORT_QUEUE_RUNTIME_READY?: string;
|
|
SCAN_QUEUE_ENABLED?: string;
|
|
WORKER_QUEUE_GROUP?: string;
|
|
} = process.env as EnvRecord
|
|
): readonly QueueName[] {
|
|
if (typeof env.WORKER_QUEUE_GROUP === "string" && isWorkerQueueGroup(env.WORKER_QUEUE_GROUP)) {
|
|
if (env.WORKER_QUEUE_GROUP === "import" && (env.IMPORT_QUEUE_ENABLED !== "true" || env.IMPORT_QUEUE_RUNTIME_READY !== "true")) {
|
|
return [];
|
|
}
|
|
return getQueueNamesForGroup(env.WORKER_QUEUE_GROUP);
|
|
}
|
|
|
|
const queues: QueueName[] = [...defaultWorkerQueueNames];
|
|
if (env.IMPORT_QUEUE_ENABLED === "true") {
|
|
queues.push(queueNames.imports);
|
|
}
|
|
if (env.EXPORT_RETENTION_QUEUE_ENABLED === "true") {
|
|
queues.push(queueNames.maintenance);
|
|
}
|
|
if (env.SCAN_QUEUE_ENABLED === "true") {
|
|
queues.push(queueNames.fileScan);
|
|
}
|
|
|
|
return queues;
|
|
}
|