Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

disyuntor

Package Overview
Dependencies
Maintainers
3
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

disyuntor - npm Package Compare versions

Comparing version 4.0.0 to 4.1.0

16

lib/Config.js

@@ -32,9 +32,2 @@ "use strict";

class DisyuntorConfig {
constructor(name, thresholdConfig, onBreakerTripEvent, onBreakerCloseEvent, shouldTriggerAsFailure = () => true) {
this.name = name;
this.thresholdConfig = thresholdConfig;
this.onBreakerTripEvent = onBreakerTripEvent;
this.onBreakerCloseEvent = onBreakerCloseEvent;
this.shouldTriggerAsFailure = shouldTriggerAsFailure;
}
/**

@@ -53,3 +46,3 @@ * Convenience method for mixed-bag time objects

else if (typeof input === 'string') {
return ms_1.default(input);
return (0, ms_1.default)(input);
}

@@ -76,3 +69,10 @@ else {

}
constructor(name, thresholdConfig, onBreakerTripEvent, onBreakerCloseEvent, shouldTriggerAsFailure = () => true) {
this.name = name;
this.thresholdConfig = thresholdConfig;
this.onBreakerTripEvent = onBreakerTripEvent;
this.onBreakerCloseEvent = onBreakerCloseEvent;
this.shouldTriggerAsFailure = shouldTriggerAsFailure;
}
}
exports.DisyuntorConfig = DisyuntorConfig;

@@ -10,3 +10,3 @@ /// <reference types="node" />

}
declare type PromiseBuilder<T> = (...args: any[]) => Promise<T>;
type PromiseBuilder<T> = (...args: any[]) => Promise<T>;
export declare class Disyuntor extends EventEmitter {

@@ -13,0 +13,0 @@ private config;

@@ -25,2 +25,5 @@ "use strict";

class Disyuntor extends events_1.EventEmitter {
get timeout() {
return this.config.thresholdConfig.callTimeoutMs;
}
constructor(params) {

@@ -43,5 +46,2 @@ super();

}
get timeout() {
return this.config.thresholdConfig.callTimeoutMs;
}
reset() {

@@ -76,3 +76,7 @@ this.failures = 0;

else if (state === State.HalfOpen) {
this.currentCooldown = Math.min(this.currentCooldown * (this.failures + 1), this.config.thresholdConfig.maxCooldownTimeMs);
/*
We add 2 because we're setting the cooldown for the case that the current call fails, and the number of trips we've observed is already equal to this.failures - this.config.thresholdConfig.maxConsecutiveFailures + 1
*/
const cooldownMultiplier = this.failures - this.config.thresholdConfig.maxConsecutiveFailures + 2;
this.currentCooldown = Math.min(this.currentCooldown * cooldownMultiplier, this.config.thresholdConfig.maxCooldownTimeMs);
}

@@ -86,3 +90,3 @@ try {

else {
const timeout = Timeout_1.create(this.config.name, this.config.thresholdConfig.callTimeoutMs, promise);
const timeout = (0, Timeout_1.create)(this.config.name, this.config.thresholdConfig.callTimeoutMs, promise);
result = yield Promise.race([timeout, promise]);

@@ -89,0 +93,0 @@ }

{
"name": "disyuntor",
"description": "A circuit-breaker implementation with exponential backoff.",
"version": "4.0.0",
"version": "4.1.0",
"author": "José F. Romaniello <jfromaniello@gmail.com> (http://joseoncode.com)",

@@ -6,0 +6,0 @@ "repository": {

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