@midwayjs/bullmq
Version:
midway component for BullMQ
37 lines • 1.36 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Processor = Processor;
exports.InjectQueue = InjectQueue;
exports.InjectWorker = InjectWorker;
exports.InjectFlowProducer = InjectFlowProducer;
const core_1 = require("@midwayjs/core");
const constants_1 = require("./constants");
function Processor(queueName, jobOptions, workerOptions, queueOptions) {
return function (target) {
core_1.DecoratorManager.saveModule(constants_1.BULLMQ_PROCESSOR_KEY, target);
core_1.MetadataManager.defineMetadata(constants_1.BULLMQ_PROCESSOR_KEY, {
queueName,
jobOptions,
workerOptions,
queueOptions,
}, target);
(0, core_1.Provide)()(target);
(0, core_1.Scope)(core_1.ScopeEnum.Request)(target);
};
}
function InjectQueue(queueName) {
return core_1.DecoratorManager.createCustomPropertyDecorator(constants_1.BULLMQ_QUEUE_KEY, {
queueName,
});
}
function InjectWorker(queueName) {
return core_1.DecoratorManager.createCustomPropertyDecorator(constants_1.BULLMQ_WORKER_KEY, {
queueName,
});
}
function InjectFlowProducer(producerName) {
return core_1.DecoratorManager.createCustomPropertyDecorator(constants_1.BULLMQ_FLOW_PRODUCER_KEY, {
producerName,
});
}
//# sourceMappingURL=decorator.js.map