Skip to content

Commit

Permalink
Return responses as an array instead of an object
Browse files Browse the repository at this point in the history
  • Loading branch information
markyen committed Feb 12, 2015
1 parent fac750f commit a27670e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ RingPop.prototype.handleOrProxyAll =
var keysByDest = _.groupBy(keys, this.lookup, this);
var dests = Object.keys(keysByDest);
var pending = dests.length;
var responses = {};
var responses = [];

dests.forEach(function(dest) {
var res = hammock.Response();
Expand Down Expand Up @@ -883,11 +883,11 @@ RingPop.prototype.handleOrProxyAll =
});

function onResponse(err, response, dest) {
responses[dest] = {
responses.push({
res: response,
dest: dest,
keys: keysByDest[dest]
};
});
if ((--pending === 0 || err) && cb) {
cb(err, responses);
cb = null;
Expand Down
6 changes: 2 additions & 4 deletions test/integration/handle_or_proxy_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,8 @@ test('handleOrProxyAll() proxies and calls local handler', function t(assert) {
function onResponses(err, responses) {
assert.ifError(err);

var hosts = Object.keys(responses);
assert.equal(hosts.length, 3);
hosts.forEach(function(host) {
var data = responses[host];
assert.equal(responses.length, 3);
responses.forEach(function(data) {
assert.equal(data.res.statusCode, 200);
tryIt(function parse() {
var body = JSON.parse(data.res.body);
Expand Down

0 comments on commit a27670e

Please sign in to comment.