airlock
Advanced tools
Comparing version 2.1.0 to 2.1.1
21
index.js
@@ -0,1 +1,3 @@ | ||
var BitRing = require('./bit-ring'); | ||
var defaults = { | ||
@@ -33,3 +35,3 @@ title: 'general', | ||
this.logger = options.logger || null; | ||
this.probes = []; | ||
this.bitRing = new BitRing(this.window); | ||
this.waitPeriod = this.defaultWaitPeriod; | ||
@@ -59,5 +61,5 @@ this.lastBackendRequest = this.now(); | ||
Prober.prototype.isHealthy = function isHealth() { | ||
return this.probes.length < this.window || | ||
this._getOks().length >= this.threshold; | ||
Prober.prototype.isHealthy = function isHealthy() { | ||
return this.bitRing.length < this.window || | ||
this.bitRing.count() >= this.threshold; | ||
}; | ||
@@ -163,3 +165,2 @@ | ||
Prober.prototype._addProbe = function addProbe(isOk) { | ||
var timestamp = this.now(); | ||
var logger = this.logger; | ||
@@ -169,5 +170,3 @@ var statsd = this.statsd; | ||
var wasHealthy = this.isHealthy(); | ||
var thisProbe = { isOk: isOk, timestamp: timestamp }; | ||
this.probes.unshift(thisProbe); | ||
this.probes = this.probes.slice(0, this.window); | ||
this.bitRing.push(isOk); | ||
var isHealthy = this.isHealthy(); | ||
@@ -196,3 +195,3 @@ | ||
if (thisProbe.isOk) { | ||
if (isOk) { | ||
this.waitPeriod /= 2; | ||
@@ -223,6 +222,2 @@ if (logger) { | ||
Prober.prototype._getOks = function _getOks() { | ||
return this.probes.filter(function(probe) { return probe.isOk; }); | ||
}; | ||
Prober.prototype._isPityProbe = function _isPityProbe() { | ||
@@ -229,0 +224,0 @@ return this.lastBackendRequest && this.now() >= |
{ | ||
"name": "airlock", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "A prober to probe HTTP based backends for health", | ||
@@ -24,6 +24,7 @@ "keywords": [], | ||
"devDependencies": { | ||
"benchmark": "^1.0.0", | ||
"istanbul": "~0.1.46", | ||
"lodash.times": "~2.4.1", | ||
"mocha": "~1.15.1", | ||
"lodash.times": "~2.4.1", | ||
"time-mock": "~0.1.2", | ||
"istanbul": "~0.1.46" | ||
"time-mock": "~0.1.2" | ||
}, | ||
@@ -30,0 +31,0 @@ "scripts": { |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
21555
14
496
5
1