Comparing version 0.6.7 to 1.0.0
@@ -187,33 +187,6 @@ (function(root, factory) { | ||
var messageHandler = function(message) { | ||
var meta = { | ||
type: 'sendMessage', | ||
replyTo: message.getMeta('id'), | ||
channel: message.getMeta('from'), | ||
inre: message.getMeta('id') | ||
}; | ||
// Link up our reply to the incoming request but on the "result" group. | ||
var groups = [group + '-result']; | ||
// CC the groups in the incoming messages CC list. | ||
if (message.hasMeta('cc.group')) { | ||
groups = groups.concat(message.getMeta('cc.group')); | ||
} | ||
if (message.hasMeta('session')) { | ||
meta.session = message.getMeta('session'); | ||
} | ||
var sendToGroup = function(message, group) { | ||
return this._send(this.mb.send(group, message)); | ||
}.bind(this); | ||
var sendToAll = function(message) { | ||
return Promise.all(groups.map(_.partial(sendToGroup, message))); | ||
}; | ||
var execute = Promise.try(cb.bind({}, message)).then(function(message) { | ||
return sendToAll( | ||
var execute = Promise.try(cb.bind({}, message)).then(function(result) { | ||
return this._send( | ||
this.mb.success( | ||
this.mb.extend({meta: meta}, this.mb.coerce(message)) | ||
this.mb.extend(this.mb.rpcReply(message), this.mb.coerce(result)) | ||
) | ||
@@ -224,4 +197,3 @@ ); | ||
var errorHandler = function(error) { | ||
var reason = _.isError(error) ? error.toString() : error; | ||
var errorMeta = _.extend({reason: reason}, meta); | ||
var errorMeta = {reason: _.isError(error) ? error.stack : error}; | ||
@@ -235,3 +207,7 @@ if (newrelic !== null) { | ||
return sendToAll(this.mb.failure({meta: errorMeta})); | ||
return this._send( | ||
this.mb.failure( | ||
this.mb.extend(this.mb.rpcReply(message), {meta: errorMeta}) | ||
) | ||
); | ||
}.bind(this); | ||
@@ -540,2 +516,23 @@ | ||
// ### HelpEsb.MessageBuilder.rpcReply | ||
// Wraps a standard send message based on an incoming RPC request message. | ||
// Sets the replyTo, channel, group, and session meta fields. | ||
HelpEsb.MessageBuilder.prototype.rpcReply = function(inre) { | ||
var meta = {replyTo: inre.getMeta('id'), channel: inre.getMeta('from')}; | ||
// Link up our reply to the incoming request but on the "result" group. | ||
var groups = [inre.getMeta('group') + '-result']; | ||
// CC the groups in the incoming messages CC list. | ||
if (inre.hasMeta('cc.group')) { | ||
groups = groups.concat(inre.getMeta('cc.group')); | ||
} | ||
if (inre.hasMeta('session')) { | ||
meta.session = inre.getMeta('session'); | ||
} | ||
return this.send(groups, {meta: meta}, inre); | ||
}; | ||
// ### HelpEsb.MessageBuilder.success | ||
@@ -618,6 +615,3 @@ // Creates a standard success message which has a result status, extending | ||
this._data = _.has(message, 'data') ? message.data : {}; | ||
this._meta = _.extend( | ||
{id: uuid.v4(), ts: Math.floor(Date.now() / 1000)}, | ||
message.meta | ||
); | ||
this._meta = _.extend({id: uuid.v4(), ts: Date.now()}, message.meta); | ||
}; | ||
@@ -624,0 +618,0 @@ |
{ | ||
"name": "help-esb", | ||
"version": "0.6.7", | ||
"version": "1.0.0", | ||
"description": "A client for the Help.com team's ESB.", | ||
@@ -5,0 +5,0 @@ "main": "help-esb.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
33961
13
647
1
7