eventstore
Advanced tools
Comparing version 1.7.2 to 1.7.3
@@ -139,3 +139,3 @@ 'use strict'; | ||
if (self.heartbeatInterval) { | ||
console.error((new Error ('Heartbeat timeouted after ' + gracePeriod + 'ms')).stack); | ||
console.error((new Error ('Heartbeat timeouted after ' + gracePeriod + 'ms (mongodb)')).stack); | ||
self.db.close(function () {}); | ||
@@ -142,0 +142,0 @@ } |
@@ -22,3 +22,7 @@ 'use strict'; | ||
snapshotsCollectionName: 'snapshots', | ||
max_attempts: 1 | ||
max_attempts: 1, | ||
retry_strategy: function (options) { | ||
return undefined; | ||
}//, | ||
// heartbeat: 60 * 1000 | ||
}; | ||
@@ -101,2 +105,3 @@ | ||
self.disconnect(); | ||
self.stopHeartbeat(); | ||
}); | ||
@@ -121,2 +126,6 @@ | ||
if (self.options.heartbeat) { | ||
self.startHeartbeat(); | ||
} | ||
if (calledBack) return; | ||
@@ -128,4 +137,41 @@ calledBack = true; | ||
stopHeartbeat: function () { | ||
if (this.heartbeatInterval) { | ||
clearInterval(this.heartbeatInterval); | ||
delete this.heartbeatInterval; | ||
} | ||
}, | ||
startHeartbeat: function () { | ||
var self = this; | ||
var gracePeriod = Math.round(this.options.heartbeat / 2); | ||
this.heartbeatInterval = setInterval(function () { | ||
var graceTimer = setTimeout(function () { | ||
if (self.heartbeatInterval) { | ||
console.error((new Error ('Heartbeat timeouted after ' + gracePeriod + 'ms (redis)')).stack); | ||
if (self.client) { | ||
self.client.end(true); | ||
} | ||
} | ||
}, gracePeriod); | ||
self.client.ping(function (err) { | ||
if (graceTimer) clearTimeout(graceTimer); | ||
if (err) { | ||
console.error(err.stack || err); | ||
if (self.client) { | ||
self.client.end(true); | ||
} | ||
} | ||
}); | ||
}, this.options.heartbeat); | ||
}, | ||
disconnect: function (callback) { | ||
this.client.end(); | ||
this.stopHeartbeat(); | ||
if (this.client) { | ||
this.client.end(true); | ||
} | ||
this.emit('disconnect'); | ||
@@ -132,0 +178,0 @@ if (callback) callback(null, this); |
{ | ||
"author": "adrai", | ||
"name": "eventstore", | ||
"version": "1.7.2", | ||
"version": "1.7.3", | ||
"contributors": [ | ||
@@ -6,0 +6,0 @@ { |
@@ -0,1 +1,4 @@ | ||
#### [v1.7.3](https://github.com/adrai/node-eventstore/compare/v1.7.2...v1.7.3) | ||
- redis: added optional heartbeat | ||
#### [v1.7.2](https://github.com/adrai/node-eventstore/compare/v1.7.1...v1.7.2) | ||
@@ -2,0 +5,0 @@ - update azure dependencies |
135642
3343