Skip to content

CircuitBreakerConfig

Thiago da Rosa de Bustamante edited this page Feb 6, 2018 · 6 revisions

Configure circuit breaker for API requests.

The Circuitbreaker configuration object must be included in the API config and supports the following properties:

Property Type Description Required
timeout string or number Exceptions or calls exceeding the configured timeout increment a failure counter. You can inform the amount of milisencods, or use a human-interval string. Defaults to '30 seconds'. false
resetTimeout string or number After the configured resetTimeout, the circuit breaker enters a 'half-open' state. You can inform the amount of milisencods, or use a human-interval string. Defaults to '2 minutes'. false
timeWindow Define a time window to count the api failures. If defined, the gateway will reset the total failures count by each period of time defined here. false
maxFailures number When the failure counter reaches a maxFailures count, the breaker is tripped into 'open' state. false
disableStats boolean If true, disable the statistical data recording for circuitbreaker events. false
statsConfig StatsConfig Configurations for circuitbreaker stats. false
onOpen MiddlewareConfig An installed 'circuitbreaker' middleware function, called when the circuit move to 'open' state. false
onClose MiddlewareConfig An installed 'circuitbreaker' middleware function, called when the circuit move to 'close' state. false
onRejected MiddlewareConfig An installed 'circuitbreaker' middleware function, called when the circuit rejected (fast fail) a request. false
timeoutMessage string Message to be sent when an api call occurs in a timeout. Defaults to: 'Operation timeout'. false
timeoutStatusCode number Status code to be sent when an api call occurs in a timeout. Defaults to: 504. false
rejectMessage string Message to be sent when an api call is rejected because circuit is open. Defaults to: 'Service unavailable'. false
rejectStatusCode number Status code to be sent when an api call is rejected because circuit is open. Defaults to: 503. false

Example:

{
    "circuitBreaker": {
        "timeout": "45 seconds",
        "resetTimeout": "2 minutes and 30 seconds",
        "maxFailures": 10,
        "onOpen": {
            "name": "myOpenHandler"
        }
    }
}
Clone this wiki locally