@lexamica-modules/job-queue
Version:
The package for the Lexamica Job Queue SDK powered by Redis and BullMQ
30 lines (27 loc) • 1.18 kB
text/typescript
import { QUEUES_INIT } from "../util/config";
import { CommonQueueManagement } from "./common";
import { Consumers } from "../types";
// ingest the global config and come up with a list of queue names to create
const INITS = Object.entries(QUEUES_INIT).reduce(
(prev: string[], [name, config]) => {
if (config.mainframe.init) {
return [...prev, name];
} else {
return prev;
}
},
[],
);
/**
* This is the instance for the central Lexamica API. This instance has access to almost all queues so that the Lexamica API can assign, manage, and process jobs.
*/
export class Mainframe extends CommonQueueManagement {
/**
* Initialize a mainframe instance using an optional manual list of queues and an optional remote Redis url
* @param connection_url if given, instance will connect to this remote Redis. Otherwise a local instance will be used.
* @param initQueues if given, local queue instances will be built off of this. Recommend not specifying this unless you know what you are doing.
*/
constructor(connection_url?: string, initQueues?: string[]) {
super(initQueues ?? INITS, Consumers.MAINFRAME, connection_url);
}
}