New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

levee

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

levee - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

40

lib/breaker.js

@@ -21,7 +21,8 @@ 'use strict';

this._impl = impl;
this._state = undefined;
this._state = Breaker.State.CLOSE;
this._numFailures = 0;
this._pendingClose = false;
this._resetTimer = undefined;
this._init();
this.on('open', this._startTimer);
}

@@ -38,21 +39,2 @@

Breaker.prototype._init = function _init() {
var timer;
function reset() {
clearTimeout(timer);
this._pendingClose = false;
this.once('open', function () {
timer = setTimeout(this.halfOpen.bind(this), this.settings.resetTimeout);
timer.unref();
});
}
this.on('half_open', reset);
this.on('close', reset);
this.close();
};
Breaker.prototype.run = function run(context, callback) {

@@ -91,2 +73,8 @@ var self, fallback, fn;

if (this.isHalfOpen()) {
// Flip the flag to disallow additional calls at this time.
// It doesn't matter if any in-flight calls come back before
// this call completes because if the in-flight ones timeout
// or fail, the command still isn't healthy so we flip back
// to `open`. If they succeed we optimistically flip back to
// `closed` and this call can continue as normal.
this._pendingClose = true;

@@ -101,2 +89,3 @@ }

timer = undefined;
self._pendingClose = false;
self.emit('timeout');

@@ -117,2 +106,3 @@ self._onFailure();

self._pendingClose = false;
self.emit('duration', Date.now() - start);

@@ -149,3 +139,2 @@

Breaker.prototype.open = function open() {
this._pendingClose = false;
this._setState(Breaker.State.OPEN);

@@ -181,2 +170,9 @@ };

Breaker.prototype._startTimer = function _startTimer() {
this._resetTimer = setTimeout(this.halfOpen.bind(this), this.settings.resetTimeout);
this._resetTimer.unref();
};
module.exports = Breaker;
{
"name": "levee",
"version": "1.0.2",
"version": "1.0.3",
"description": "A circuitbreaker implementation for Node.js",

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

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