github.com/hellofresh/janus@v0.0.0-20230925145208-ce8de8183c67/docs/plugins/cb.md (about) 1 # Circuit Breaker 2 3 Janus has a circuit breaker plugin that can be configured for each endpoint. You can check 4 our [example](https://github.com/hellofresh/janus/tree/master/examples/plugin-cb) on how 5 to use the plugin. 6 7 ## Configuration 8 9 The plain cb config: 10 11 ```json 12 { 13 "name" : "cb", 14 "enabled" : true, 15 "config" : { 16 "name": "my-circuit-breaker", 17 "timeout" : 1000, 18 "max_concurrent_requests": 100, 19 "error_percent_threshold": 50, 20 "request_volume_threshold": 20, 21 "sleep_window": 5000, 22 "predicate": "statusCode == 0 || statusCode >= 500" 23 } 24 } 25 ``` 26 27 Configuration | Description 28 :---|:---| 29 | name | Circuit Breaker name to group stats | 30 | timeout | Timeout that the CB will wait till the request responds | 31 | max_concurrent_requests | How many commands of the same type can run at the same time | 32 | error_percent_threshold | Causes circuits to open once the rolling measure of errors exceeds this percent of requests | 33 | request_volume_threshold | Is the minimum number of requests needed before a circuit can be tripped due to health | 34 | sleep_window | Is how long, in milliseconds, to wait after a circuit opens before testing for recovery | 35 | predicate | The rule that we will check to define if the request was successful or not. You have access to `statusCode` and all the `request` object. Defaults to `statusCode == 0 \|\| statusCode >= 500` |