-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add circuit.shutdown() to shut a circuit down
Shutting down a circuit will cause it to always return a rejected promise with an `ESHUTDOWN` `Error.code` when `circuit.fire()` is called, and the Hystrix stats stop accumulating. Once a circuit has been shut down, it cannot be reset or used again. When using the `shutdown()` method on a circuit, all listeners are cleaned up internally, preventing memory leaks. Fixes: #248 Fixes: #181 Fixes: #245
- Loading branch information
Showing
12 changed files
with
163 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
'use strict'; | ||
|
||
const test = require('tape'); | ||
const circuit = require('..'); | ||
const passFail = require('./common').passFail; | ||
|
||
// tests that we are not leaving listeners open to | ||
// chew up memory | ||
test('EventEmitter max listeners', t => { | ||
let i = 100; | ||
while (--i >= 0) { | ||
const breaker = circuit(passFail); | ||
breaker.fire(1); | ||
breaker.shutdown(); // required for cleanup | ||
} | ||
t.end(); | ||
}); | ||
|
||
test('Circuit shuts down properly', t => { | ||
t.plan(3); | ||
const breaker = circuit(passFail); | ||
t.ok(breaker.fire(1), 'breaker is active'); | ||
breaker.shutdown(); | ||
t.ok(breaker.isShutdown, 'breaker is shutdown'); | ||
t.notOk(breaker.enabled, 'breaker has been disabled'); | ||
t.end(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.