-
-
Save kristofsajdak/d57e5373a58f9a41d538 to your computer and use it in GitHub Desktop.
Generic template for event consumer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//keys are generated from the collection names. | |
var orderedAlarmsChangeConsumer = queue({exchange, "name":"ordered.alarms", exclusive:false}).consume( | |
'canAlarms.insert': function(data) { | |
if(data.canAlarms[0].archiveRequested){ | |
return createAndSendCanAlarms(data) | |
}, | |
'canAlarms.delete': function ... , | |
'canAlarams.update': function ... , | |
'trackingData.insert': function... , | |
'trackingData.delete':function ... , | |
'trackingData.update':function ... , | |
'equipment.#': function ... , | |
'foo.bar.baz': function ... | |
}, | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
queue({exchange, "name":"consoleLogs", keys: ['log.warn', 'log.info']}).consume( | |
function(data, msg) { | |
console.log(data) | |
return Promise.resolve() | |
} | |
) | |
queue({exchange, "name":"errorFile", keys: ['log.error', 'log.critical']}).consume( | |
function(data) { | |
return sendEmail(data) | |
} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment