@cavai/adonis-queue
Version:
Basic AdonisJS queue provider
21 lines (20 loc) • 660 B
JavaScript
// Check up stuff from https://github.com/adonisjs/core/blob/next/modules/hash/drivers_collection.ts
/**
* A singleton collection of drivers for the entire lifecycle of
* the application.
*/
class DriversCollection {
list = {};
extend(driverName, factoryCallback) {
this.list[driverName] = factoryCallback;
return this;
}
create(name, config) {
const driverFactory = this.list[name];
if (!driverFactory) {
throw new Error(`Unknown queue driver "${String(name)}". Make sure the driver is registered`);
}
return driverFactory(config);
}
}
export default new DriversCollection();