@midwayjs/bullmq
Version:
midway component for BullMQ
60 lines • 2.67 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.BullConfiguration = void 0;
const core_1 = require("@midwayjs/core");
const DefaultConfig = require("./config/config.default");
const framework_1 = require("./framework");
const constants_1 = require("./constants");
let BullConfiguration = class BullConfiguration {
framework;
decoratorService;
async init() {
this.decoratorService.registerPropertyHandler(constants_1.BULLMQ_QUEUE_KEY, (propertyName, meta) => {
return this.framework.getQueue(meta.queueName);
});
this.decoratorService.registerPropertyHandler(constants_1.BULLMQ_WORKER_KEY, (propertyName, meta) => {
return this.framework.getWorker(meta.queueName);
});
this.decoratorService.registerPropertyHandler(constants_1.BULLMQ_FLOW_PRODUCER_KEY, (propertyName, meta) => {
return this.framework.getFlowProducer(meta.producerName);
});
}
async onReady() {
this.framework.loadConfig();
}
};
exports.BullConfiguration = BullConfiguration;
__decorate([
(0, core_1.Inject)(),
__metadata("design:type", framework_1.BullMQFramework)
], BullConfiguration.prototype, "framework", void 0);
__decorate([
(0, core_1.Inject)(),
__metadata("design:type", core_1.MidwayDecoratorService)
], BullConfiguration.prototype, "decoratorService", void 0);
__decorate([
(0, core_1.Init)(),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Promise)
], BullConfiguration.prototype, "init", null);
exports.BullConfiguration = BullConfiguration = __decorate([
(0, core_1.Configuration)({
namespace: 'bullmq',
importConfigs: [
{
default: DefaultConfig,
},
],
})
], BullConfiguration);
//# sourceMappingURL=configuration.js.map