@cavai/adonis-queue
Version:
> Basic AdonisJS queue provider
25 lines (24 loc) • 775 B
JavaScript
;
// Check up stuff from https://github.com/adonisjs/core/blob/next/modules/hash/drivers_collection.ts
Object.defineProperty(exports, "__esModule", { value: true });
/**
* A singleton collection of drivers for the entire lifecycle of
* the application.
*/
class DriversCollection {
constructor() {
this.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);
}
}
exports.default = new DriversCollection();