UNPKG

inceptum

Version:

hipages take on the foundational library for enterprise-grade apps written in NodeJS

35 lines 1.62 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const BaseSingletonDefinition_1 = require("../ioc/objectdefinition/BaseSingletonDefinition"); const RabbitmqConsumer_1 = require("./RabbitmqConsumer"); class RabbitmqConsumerPlugin { constructor() { this.name = 'RabbitmqConsumerPlugin'; } getName() { return this.name; } willStart(app) { if (!app.hasConfig('rabbitmq')) { throw new Error('RabbitmqPlugin has been registered but could not find config using key "rabbitmq"'); } const context = app.getContext(); const clientConf = context.getConfig('rabbitmq.client'); const confs = context.getConfig('rabbitmq.consumer'); Object.keys(confs).forEach((key) => { const clientType = 'consumer'; const name = `${key}_${clientType}`; const consumerSingleton = new BaseSingletonDefinition_1.BaseSingletonDefinition(RabbitmqConsumer_1.RabbitmqConsumer, name); consumerSingleton.constructorParamByValue(clientConf); consumerSingleton.constructorParamByValue(name); consumerSingleton.constructorParamByValue(confs[key]); consumerSingleton.constructorParamByRef(confs[key]['messageHandler']); consumerSingleton.startFunction('init'); consumerSingleton.stopFunction('close'); consumerSingleton.withLazyLoading(false); context.registerSingletons(consumerSingleton); }); } } exports.default = RabbitmqConsumerPlugin; //# sourceMappingURL=RabbitmqConsumerPlugin.js.map