Skip to content

Commit

Permalink
fix: semaphore is part of the class
Browse files Browse the repository at this point in the history
as property
  • Loading branch information
helio-frota committed Jun 13, 2017
1 parent e62a569 commit 0faa766
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/circuit.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class CircuitBreaker extends EventEmitter {
this.options.rollingCountBuckets = options.rollingCountBuckets || 10;
this.options.rollingPercentilesEnabled = options.rollingPercentilesEnabled !== false;
this.options.capacity = options.capacity || 10;
this.semaphore = new Semaphore(this.options.capacity);

this[STATUS] = new Status(this.options);
this[STATE] = CLOSED;
Expand Down Expand Up @@ -237,7 +238,6 @@ class CircuitBreaker extends EventEmitter {
* @fires CircuitBreaker#timeout
*/
fire () {
const semaphore = new Semaphore(this.options.capacity);
const args = Array.prototype.slice.call(arguments);

/**
Expand Down Expand Up @@ -277,7 +277,7 @@ class CircuitBreaker extends EventEmitter {

let timeout;
let timeoutError = false;
return semaphore.use(() => {
return this.semaphore.use(() => {
return new Promise((resolve, reject) => {
const latencyStartTime = Date.now();
timeout = setTimeout(
Expand Down

0 comments on commit 0faa766

Please sign in to comment.