Rename _id to _msgid to avoid mongo clash

This commit is contained in:
Nick O'Leary 2015-02-06 16:36:32 +00:00
parent f2712f296b
commit 3849855b57
2 changed files with 12 additions and 12 deletions

View File

@ -96,8 +96,8 @@ Node.prototype.send = function(msg) {
// A single message and a single wire on output 0
// TODO: pre-load flows.get calls - cannot do in constructor
// as not all nodes are defined at that point
if (!msg._id) {
msg._id = constructUniqueIdentifier();
if (!msg._msgid) {
msg._msgid = constructUniqueIdentifier();
}
this.metric("send",msg);
node = flows.get(this._wire);
@ -136,7 +136,7 @@ Node.prototype.send = function(msg) {
for (k = 0; k < msgs.length; k++) {
var m = msgs[k];
if (!sentMessageId) {
sentMessageId = m._id;
sentMessageId = m._msgid;
}
if (msgSent) {
var clonedmsg = redUtil.cloneMessage(m);
@ -154,12 +154,12 @@ Node.prototype.send = function(msg) {
if (!sentMessageId) {
sentMessageId = constructUniqueIdentifier();
}
this.metric("send",{_id:sentMessageId});
this.metric("send",{_msgid:sentMessageId});
for (i=0;i<sendEvents.length;i++) {
var ev = sendEvents[i];
if (!ev.m._id) {
ev.m._id = sentMessageId;
if (!ev.m._msgid) {
ev.m._msgid = sentMessageId;
}
ev.n.receive(ev.m);
}
@ -169,8 +169,8 @@ Node.prototype.receive = function(msg) {
if (!msg) {
msg = {};
}
if (!msg._id) {
msg._id = constructUniqueIdentifier();
if (!msg._msgid) {
msg._msgid = constructUniqueIdentifier();
}
this.metric("receive",msg);
this.emit("input", msg);
@ -212,7 +212,7 @@ Node.prototype.metric = function(eventname, msg, metricValue) {
metrics.level = Log.METRIC;
metrics.nodeid = this.id;
metrics.event = "node."+this.type+"."+eventname;
metrics.msgid = msg._id;
metrics.msgid = msg._msgid;
metrics.value = metricValue;
Log.log(metrics);
}

View File

@ -91,7 +91,7 @@ describe('Node', function() {
var n = new RedNode({id:'123',type:'abc'});
n.on('input',function(msg) {
(typeof msg).should.not.be.equal("undefined");
(typeof msg._id).should.not.be.equal("undefined");
(typeof msg._msgid).should.not.be.equal("undefined");
done();
});
n.receive();
@ -101,7 +101,7 @@ describe('Node', function() {
var n = new RedNode({id:'123',type:'abc'});
n.on('input',function(msg) {
(typeof msg).should.not.be.equal("undefined");
(typeof msg._id).should.not.be.equal("undefined");
(typeof msg._msgid).should.not.be.equal("undefined");
done();
});
n.receive(null);
@ -400,7 +400,7 @@ describe('Node', function() {
sinon.stub(Log, 'log', function(msg) {
loginfo = msg;
});
var msg = {payload:"foo", _id:"987654321"};
var msg = {payload:"foo", _msgid:"987654321"};
n.metric("test.metric",msg,"15mb");
should.deepEqual({value:"15mb", level:Log.METRIC, nodeid:n.id,
event:"node.abc.test.metric",msgid:"987654321"}, loginfo);