memcached
Advanced tools
Comparing version 0.2.4 to 0.2.5
@@ -0,1 +1,5 @@ | ||
### 0.2.5 | ||
- Fix for two bugs in Issuelog #137 and #141 | ||
- Add new `failuresTimeout` option | ||
### 0.2.4 | ||
@@ -2,0 +6,0 @@ - Tons of fixes have been made to the way we do error handling and failover, |
@@ -47,2 +47,8 @@ "use strict"; | ||
this.messages.push(message || 'No message specified'); | ||
// All failures must occur within `failuresTimeout` ms from the initial | ||
// failure in order for node to be disconnected or removed. | ||
if (this.failures && this.failures == this.config.failures) | ||
this.failuresResetId = setTimeout(issue.failuresReset.bind(issue), this.failuresTimeout); | ||
if (this.failures && !this.locked) { | ||
@@ -54,2 +60,4 @@ this.locked = true; | ||
if (this.failuresResetId) clearTimeout(this.failuresResetId); | ||
if (this.remove) return this.emit('remove', this.details); | ||
@@ -63,2 +71,7 @@ | ||
issues.failuresReset = function failuresReset() { | ||
//this.failures = this.config.failures; | ||
Utils.merge(this, JSON.parse(JSON.stringify(this.config))); | ||
}; | ||
Object.defineProperty(issues, 'details', { | ||
@@ -102,3 +115,3 @@ get: function getDetails () { | ||
if (err) { | ||
this.messages.push(err.message || 'No message specified'); | ||
issue.messages.push(err.message || 'No message specified'); | ||
return setTimeout(issue.attemptReconnect.bind(issue), issue.reconnect); | ||
@@ -105,0 +118,0 @@ } |
@@ -86,2 +86,3 @@ "use strict"; | ||
, failures: 5 // Number of times a server can have an issue before marked dead | ||
, failuresTimeout: 300000 // Time after which `failures` will be reset to original value, since last failure | ||
, retry: 30000 // When a server has an error, wait this amount of time before retrying | ||
@@ -369,2 +370,3 @@ , idle: 5000 // Remove connection from pool when no I/O after `idle` ms | ||
, failures: this.failures | ||
, failuresTimeout: this.failuresTimeout | ||
, retry: this.retry | ||
@@ -445,3 +447,3 @@ , remove: this.remove | ||
, 'SERVER_ERROR': function servererror(tokens, dataSet, err, queue, S, memcached) { | ||
(memcached || this.memcached).connectionIssue(tokens.splice(1).join(' '), S); | ||
(memcached || this.memcached).connectionIssue(tokens.splice(1).join(' '), this); | ||
return [CONTINUE, false]; | ||
@@ -448,0 +450,0 @@ } |
{ | ||
"name": "memcached" | ||
, "version": "0.2.4" | ||
, "version": "0.2.5" | ||
, "author": "Arnout Kazemier" | ||
@@ -5,0 +5,0 @@ , "description": "A fully featured Memcached API client, supporting both single and clustered Memcached servers through consistent hashing and failover/failure. Memcached is rewrite of nMemcached, which will be deprecated in the near future." |
@@ -231,4 +231,28 @@ //global it | ||
}); | ||
}); | ||
it('should reset failures if all failures do not occur within failuresTimeout ms', function(done) { | ||
var server = '10.255.255.255:1234' | ||
, memcached = new Memcached(server, { | ||
retries: 0, | ||
timeout: 10, | ||
idle: 1000, | ||
retry: 10, | ||
failures: 2, | ||
failuresTimeout: 100 }); | ||
memcached.get('idontcare', function(err) { | ||
assert.throws(function() { throw err }, /Timed out while trying to establish connection/); | ||
// Allow `retry` ms to pass, which will decrement failures | ||
setTimeout(function() { | ||
assert.deepEqual(memcached.issues[server].failures, 1); | ||
// Allow failuresTimeout ms to pass, which should reset failures | ||
setTimeout(function() { | ||
assert.deepEqual(memcached.issues[server].failures, | ||
memcached.issues[server].config.failures); | ||
memcached.end(); | ||
done(); | ||
}, 100); | ||
}, 15); | ||
}); | ||
}); | ||
}); |
496956
3798