Created
March 14, 2016 16:32
-
-
Save drobiazko/98912e54fcc616db6f94 to your computer and use it in GitHub Desktop.
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
"use strict"; | |
var Q = require("q"); | |
exports.process = function (msg, conf) { | |
let msgId = msg.id; | |
console.log("Received new message with id", msgId); | |
console.log(msg); | |
var self = this; | |
Q() | |
.then(emitData) | |
.fail(onError) | |
.finally(onEnd); | |
function emitData() { | |
console.log("Emitting data of message:", msgId); | |
self.emit('data', msg); | |
} | |
function onError(e) { | |
console.log(e); | |
self.emit('error', e); | |
} | |
function onEnd() { | |
console.log("Finished processing message:", msgId); | |
self.emit('end'); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment