Comparing version 1.6.12 to 1.6.13
@@ -20,3 +20,4 @@ 'use strict'; | ||
dbName: 'readmodel', | ||
collectionName: 'revision' | ||
collectionName: 'revision'//, | ||
// heartbeat: 60 * 1000 | ||
}; | ||
@@ -66,2 +67,3 @@ | ||
self.emit('disconnect'); | ||
self.stopHeartbeat(); | ||
}); | ||
@@ -79,2 +81,6 @@ | ||
self.emit('connect'); | ||
if (self.options.heartbeat) { | ||
self.startHeartbeat(); | ||
} | ||
} | ||
@@ -96,3 +102,34 @@ if (callback) callback(err, self); | ||
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')).stack); | ||
self.db.close(function () {}); | ||
} | ||
}, gracePeriod); | ||
self.db.command({ ping: 1 }, function (err) { | ||
if (graceTimer) clearTimeout(graceTimer); | ||
if (err) { | ||
console.error(err.stack || err); | ||
self.db.close(function () {}); | ||
} | ||
}); | ||
}, this.options.heartbeat); | ||
}, | ||
disconnect: function (callback) { | ||
this.stopHeartbeat(); | ||
if (!this.db) { | ||
@@ -99,0 +136,0 @@ if (callback) callback(null); |
@@ -20,3 +20,4 @@ 'use strict'; | ||
dbName: 'domain', | ||
collectionName: 'saga' | ||
collectionName: 'saga'//, | ||
// heartbeat: 60 * 1000 | ||
}; | ||
@@ -66,2 +67,3 @@ | ||
self.emit('disconnect'); | ||
self.stopHeartbeat(); | ||
}); | ||
@@ -81,2 +83,6 @@ | ||
self.emit('connect'); | ||
if (self.options.heartbeat) { | ||
self.startHeartbeat(); | ||
} | ||
} | ||
@@ -98,3 +104,34 @@ if (callback) callback(err, self); | ||
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')).stack); | ||
self.db.close(function () {}); | ||
} | ||
}, gracePeriod); | ||
self.db.command({ ping: 1 }, function (err) { | ||
if (graceTimer) clearTimeout(graceTimer); | ||
if (err) { | ||
console.error(err.stack || err); | ||
self.db.close(function () {}); | ||
} | ||
}); | ||
}, this.options.heartbeat); | ||
}, | ||
disconnect: function (callback) { | ||
this.stopHeartbeat(); | ||
if (!this.db) { | ||
@@ -101,0 +138,0 @@ if (callback) callback(null); |
{ | ||
"author": "adrai", | ||
"name": "cqrs-saga", | ||
"version": "1.6.12", | ||
"version": "1.6.13", | ||
"private": false, | ||
@@ -19,3 +19,3 @@ "main": "index.js", | ||
"lodash": "3.10.1", | ||
"node-uuid": "1.4.3", | ||
"node-uuid": "1.4.7", | ||
"parent-require": "1.0.0", | ||
@@ -31,3 +31,3 @@ "tolerance": "1.0.0" | ||
"mongodb": ">= 0.0.1", | ||
"redis": ">= 0.10.1", | ||
"redis": "2.3.x >= 0.10.1", | ||
"tingodb": ">= 0.0.1" | ||
@@ -34,0 +34,0 @@ }, |
@@ -0,1 +1,4 @@ | ||
## [v1.6.13](https://github.com/adrai/node-cqrs-saga/compare/v1.6.12...v1.6.13) | ||
- mongodb: added optional heartbeat | ||
## [v1.6.12](https://github.com/adrai/node-cqrs-saga/compare/v1.6.11...v1.6.12) | ||
@@ -2,0 +5,0 @@ - redis: fix wrong multi response handling |
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
162548
4408
+ Addednode-uuid@1.4.7(transitive)
- Removednode-uuid@1.4.3(transitive)
Updatednode-uuid@1.4.7