Comparing version 0.6.2 to 0.6.4
@@ -26,3 +26,3 @@ /*! | ||
var VERSION = '0.6.2', | ||
var VERSION = '0.6.4', | ||
@@ -151,9 +151,9 @@ DEFAULT_PORT = 4222, | ||
function shuffle(array) { | ||
for (var i = array.length - 1; i > 0; i--) { | ||
var j = Math.floor(Math.random() * (i + 1)); | ||
var temp = array[i]; | ||
array[i] = array[j]; | ||
array[j] = temp; | ||
} | ||
return array; | ||
for (var i = array.length - 1; i > 0; i--) { | ||
var j = Math.floor(Math.random() * (i + 1)); | ||
var temp = array[i]; | ||
array[i] = array[j]; | ||
array[j] = temp; | ||
} | ||
return array; | ||
} | ||
@@ -881,2 +881,17 @@ | ||
/** | ||
* Push a new cluster server. | ||
* | ||
* @param {String} uri | ||
* @api public | ||
*/ | ||
Client.prototype.addServer = function(uri) { | ||
this.servers.push(new Server(url.parse(uri))); | ||
if (this.options.noRandomize !== true) { | ||
shuffle(this.servers); | ||
} | ||
}; | ||
/** | ||
* Flush outbound queue to server and call optional callback when server has processed | ||
@@ -883,0 +898,0 @@ * all data. |
{ | ||
"name": "nats", | ||
"version": "0.6.2", | ||
"version": "0.6.4", | ||
"description": "Node.js client for NATS, a lightweight, high-performance cloud native messaging system", | ||
@@ -44,12 +44,13 @@ "keywords": [ | ||
"devDependencies": { | ||
"jshint": "2.8.x", | ||
"jshint-stylish": "2.0.x", | ||
"mocha": "2.2.x", | ||
"mocha-multi": "0.7.x", | ||
"mocha-lcov-reporter": "^0.0.2", | ||
"jshint": "2.9.x", | ||
"jshint-stylish": "2.2.x", | ||
"mocha": "2.5.x", | ||
"mocha-multi": "0.9.x", | ||
"mocha-lcov-reporter": "1.2.x", | ||
"dependency-check": "2.5.x", | ||
"istanbul": "^0.3.17", | ||
"istanbul": "0.4.x", | ||
"coveralls": "^2.11.2", | ||
"should": ">= 7.0.0" | ||
} | ||
"should": ">= 9.0.0" | ||
}, | ||
"typings": "./index.d.ts" | ||
} |
@@ -195,3 +195,3 @@ # NATS - Node.js Client | ||
Copyright (c) 2015 Apcera Inc.<br/> | ||
Copyright (c) 2015-2016 Apcera Inc.<br/> | ||
Copyright (c) 2011-2015 Derek Collison | ||
@@ -198,0 +198,0 @@ |
@@ -121,2 +121,19 @@ /* jslint node: true */ | ||
it('should add a new cluster server', function(done){ | ||
var servers = [uri,'nats://localhost:22223']; | ||
var nc = NATS.connect({servers: new Array(servers[0])}); | ||
var contains = 0; | ||
nc.on('connect', function(client) { | ||
client.addServer(servers[1]); | ||
client.servers.forEach(function(_server) { | ||
if (servers.indexOf(_server.url.href) !== -1) | ||
contains++; | ||
}); | ||
contains.should.equal(servers.length); | ||
done(); | ||
}); | ||
}); | ||
}); |
@@ -24,24 +24,2 @@ /* jslint node: true */ | ||
it('should process all msgs before other events with no yield', function(done) { | ||
var nc = NATS.connect(PORT); | ||
var start = Date.now(); | ||
var timer = setInterval(function() { | ||
var delta = Date.now() - start; | ||
delta.should.greaterThan(200); | ||
nc.close(); | ||
clearTimeout(timer); | ||
done(); | ||
}, 10); | ||
nc.subscribe('foo', function() { | ||
sleep.sleep(1); | ||
}); | ||
for (var i = 0; i < 256; i++) { | ||
nc.publish('foo', 'hello world'); | ||
} | ||
}); | ||
it('should yield to other events', function(done) { | ||
@@ -54,5 +32,5 @@ var nc = NATS.connect({port: PORT, yieldTime: 5}); | ||
var delta = Date.now() - start; | ||
delta.should.within(10, 20); | ||
nc.close(); | ||
clearTimeout(timer); | ||
delta.should.within(10, 20); | ||
done(); | ||
@@ -59,0 +37,0 @@ }, 10); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
126203
49
3493