Socket
Socket
Sign inDemoInstall

viewmodel

Package Overview
Dependencies
Maintainers
2
Versions
109
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

viewmodel - npm Package Compare versions

Comparing version 1.5.8 to 1.5.9

39

lib/databases/mongodb.js

@@ -21,3 +21,4 @@ 'use strict';

port: 27017,
dbName: 'context'
dbName: 'context'//,
// heartbeat: 60 * 1000
};

@@ -67,2 +68,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);

2

package.json
{
"author": "adrai",
"name": "viewmodel",
"version": "1.5.8",
"version": "1.5.9",
"private": false,

@@ -6,0 +6,0 @@ "main": "index.js",

@@ -0,1 +1,4 @@

## [v1.5.9](https://github.com/adrai/node-viewmodel/compare/v1.5.8...v1.5.9)
- mongodb: added optional heartbeat
## [v1.5.8](https://github.com/adrai/node-viewmodel/compare/v1.5.7...v1.5.8)

@@ -2,0 +5,0 @@ - mongodb: do not call ensureIndexes on clear

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc