-
Notifications
You must be signed in to change notification settings - Fork 44
ApiCircuitBreakerConfig
Thiago da Rosa de Bustamante edited this page Feb 6, 2018
·
1 revision
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 |
| group | string[] | A list of group names that should be cached by this configuration. If not provided, everything will be cached. | 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 |
| use | string | Import a configuration from gateway config session | false |
Example:
{
"circuitBreaker": [{
"timeout": "45 seconds",
"resetTimeout": "2 minutes and 30 seconds",
"maxFailures": 10,
"onOpen": {
"name": "myOpenHandler"
},
"group": ["Group1"]
},
{
"timeout": "15 seconds",
"resetTimeout": "2 minutes",
"maxFailures": 10,
"onOpen": {
"name": "myOpenHandler"
},
"group": ["Group2"]
},
{
"use": "my-circuit-breaker",
"group": ["Default"]
}]
}