UNPKG

824 BJavaScriptView Raw
1const mq = require('./RabbitMessageCenter'),
2 __ = require('underscore');
3
4const startup = (config) => {
5 return mq.start(config)
6 .then(() => {
7 __.each(config.exchanges, (ex, exName) => {
8 if (ex.publishes && ex.publishes.length > 0) {
9 let exPublishes = {}
10 ex.publishes.forEach((p) => {
11 exPublishes[p] = (msg) => {
12 return mq.publish(exName, p, msg)
13 }
14 })
15 if (ex.isDefault) {
16 Object.assign(MC, exPublishes)
17 } else {
18 MC[ex] = exPublishes
19 }
20 }
21 })
22 })
23}
24
25const MC = {
26 start: startup,
27}
28
29module.exports = MC
\No newline at end of file