Skip to content

Instantly share code, notes, and snippets.

@drobiazko
Created March 14, 2016 16:32
Show Gist options
  • Save drobiazko/98912e54fcc616db6f94 to your computer and use it in GitHub Desktop.
Save drobiazko/98912e54fcc616db6f94 to your computer and use it in GitHub Desktop.
"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