When you click the button here, this simple app calls a flakey web service that takes longer and longer to respond. The app's circuit breaker is configured to timeout after 500ms and execute a fallback command. Every 20 seconds, the flakey service is reset and the pattern is repeated.
- If more than 3 errors are observed by the circuit within a single timeout period, then it begins to fail fast, rejecting the network call outright and executing the fallback function.
-
-
- This should allow you to see all of the various events that occur when using a circuit breaker.
+ If more than half of the requests error, then it begins to fail fast, rejecting the network call outright and executing the fallback function.
- The source code for the application is relatively simple, and uses some basic jQuery capabilities to make the ajax calls and update the DOM accordingly.
+ The source code.
When you click the button here, this simple app calls a flakey web service that takes longer and longer to respond. The app's circuit breaker is configured to timeout after 500ms and execute a fallback command. Every 20 seconds, the flakey service is reset and the pattern is repeated.
- If more than 3 errors are observed by the circuit within a single timeout period, then it begins to fail fast, rejecting the network call outright and executing the fallback function.
-
-
- This should allow you to see all of the various events that occur when using a circuit breaker.
+ If more than half of the requests error, then it begins to fail fast, rejecting the network call outright and executing the fallback function.
- The source code for the application is relatively simple, and uses some basic jQuery capabilities to make the ajax calls and update the DOM accordingly.
+ The source code.
-
+
+
Circuit Breaker Statistics
+
...
+
-
FLAKEY RESPONSES
+
Flakey Responses
Click to clear
diff --git a/lib/status.js b/lib/status.js
index 562b857a..21516134 100644
--- a/lib/status.js
+++ b/lib/status.js
@@ -61,8 +61,8 @@ class Status extends EventEmitter {
this[TIMEOUT] = options.rollingCountTimeout;
this[WINDOW] = new Array(this[BUCKETS]);
- // prime the window with an initial bucket
- nextBucket(this[WINDOW])();
+ // prime the window with buckets
+ for (let i = 0; i < this[BUCKETS]; i++) this[WINDOW][i] = bucket();
// rotate the buckets periodically
const bucketInterval = Math.floor(this[TIMEOUT] / this[BUCKETS]);