circuitbreaker
The circuitbreaker middleware prevents fn invocations in the face of errors.
fnrunner Key
fnrun.middleware/circuitbreaker
Configuration
The following table describes the keys on the configuration object for the circuitbreaker middleware.
Key | Type | Default | Description |
---|---|---|---|
name | String | "" | The name of the circuit breaker |
maxRequests | Integer | 1 | The max number of requests to allow through when the circuit breaker is half-open |
interval | Duration | 60s | The period at which the internal counts are cleared |
timeout | Duration | 60s | The duration of the open state before moving into the half-open state |
Examples
The following applies a circuit breaker to prevent calling the remote endpoint if it has had several failures in a small window of time.
source: fnrun.source/http
middleware:
- fnrun.middleware/circuitbreaker:
name: myBreaker
fn:
fnrun.fn/http:
targetURL: http://example.com/some-endpoint