From 4a8b98b5ad7f6db3d446d24ee406b80da369d6ce Mon Sep 17 00:00:00 2001 From: Ruhan Date: Tue, 2 Oct 2018 11:13:38 -0300 Subject: [PATCH] feat: change default capacity from 10 to MAX_SAFE_INTEGER --- lib/circuit.js | 2 +- test/test.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/circuit.js b/lib/circuit.js index af356f55..de977644 100644 --- a/lib/circuit.js +++ b/lib/circuit.js @@ -74,7 +74,7 @@ class CircuitBreaker extends EventEmitter { this.options.rollingCountBuckets = options.rollingCountBuckets || 10; this.options.rollingPercentilesEnabled = options.rollingPercentilesEnabled !== false; - this.options.capacity = Number.isInteger(options.capacity) ? options.capacity : 10; + this.options.capacity = Number.isInteger(options.capacity) ? options.capacity : Number.MAX_SAFE_INTEGER; this.semaphore = new Semaphore(this.options.capacity); diff --git a/test/test.js b/test/test.js index e257c127..079d97b5 100644 --- a/test/test.js +++ b/test/test.js @@ -786,6 +786,12 @@ test('CircuitBreaker semaphore rate limiting', t => { }); }); +test('CircuitBreaker default capacity', t => { + const breaker = circuit(passFail); + t.equals(breaker.options.capacity, Number.MAX_SAFE_INTEGER); + t.end(); +}); + const noop = _ => {}; const common = require('./common'); const identity = common.identity;