Socket
Socket
Sign inDemoInstall

airlock

Package Overview
Dependencies
0
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.0 to 2.1.1

benchmark.js

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": {

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc