viewmodel
Advanced tools
Comparing version 1.5.11 to 1.5.12
@@ -113,3 +113,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 () {}); | ||
@@ -116,0 +116,0 @@ } |
@@ -20,3 +20,7 @@ 'use strict'; | ||
port: 6379, | ||
max_attempts: 1 | ||
max_attempts: 1, | ||
retry_strategy: function (options) { | ||
return undefined; | ||
}//, | ||
// heartbeat: 60 * 1000 | ||
}; | ||
@@ -79,2 +83,3 @@ | ||
self.disconnect(); | ||
self.stopHeartbeat(); | ||
}); | ||
@@ -99,2 +104,6 @@ | ||
if (self.options.heartbeat) { | ||
self.startHeartbeat(); | ||
} | ||
if (calledBack) return; | ||
@@ -106,5 +115,40 @@ 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.stopHeartbeat(); | ||
if (this.client) { | ||
this.client.end(); | ||
this.client.end(true); | ||
} | ||
@@ -111,0 +155,0 @@ this.emit('disconnect'); |
{ | ||
"author": "adrai", | ||
"name": "viewmodel", | ||
"version": "1.5.11", | ||
"version": "1.5.12", | ||
"private": false, | ||
@@ -6,0 +6,0 @@ "main": "index.js", |
@@ -0,1 +1,4 @@ | ||
## [v1.5.12](https://github.com/adrai/node-viewmodel/compare/v1.5.11...v1.5.12) | ||
- redis: added optional heartbeat | ||
## [v1.5.11](https://github.com/adrai/node-viewmodel/compare/v1.5.10...v1.5.11) | ||
@@ -2,0 +5,0 @@ - azuretable: array properties were not properly stored in entity [#44](https://github.com/adrai/node-viewmodel/pull/44) thanks to [mpseidel](https://github.com/mpseidel) |
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
105924
2860