Safe Haskell | None |
---|---|
Language | Haskell2010 |
Module containing circuit breaker functionality, which is the ability to open a circuit once a number of failures have occurred, thereby preventing later calls from attempting to make unsuccessful calls. | Often this is useful if the underlying service were to repeatedly time out, so as to reduce the number of calls inflight holding up upstream callers.
- data CircuitBreakerOptions
- data CircuitBreakerStatus
- data CircuitBreakerException = CircuitBreakerException String
- defaultCircuitBreakerOptions :: CircuitBreakerOptions
- circuitBreaker :: (MonadBaseControl IO m, MonadBaseControl IO n) => CircuitBreakerOptions -> BasicService m a b -> n (IORef CircuitBreakerStatus, BasicService m a b)
- maxBreakerFailures :: CircuitBreakerOptions -> Int
- resetTimeoutSecs :: CircuitBreakerOptions -> Int
- breakerDescription :: CircuitBreakerOptions -> String
Documentation
data CircuitBreakerOptions Source
Options for determining behaviour of circuit breaking services.
data CircuitBreakerStatus Source
Status indicating if the circuit is open.
data CircuitBreakerException Source
Exception thrown when the circuit is open.
defaultCircuitBreakerOptions :: CircuitBreakerOptions Source
Defaulted options for the circuit breaker with 3 failures over 60 seconds.
:: (MonadBaseControl IO m, MonadBaseControl IO n) | |
=> CircuitBreakerOptions | Options for specifying the circuit breaker behaviour. |
-> BasicService m a b | Service to protect with the circuit breaker. |
-> n (IORef CircuitBreakerStatus, BasicService m a b) |
Circuit breaking services can be constructed with this function.
maxBreakerFailures :: CircuitBreakerOptions -> Int Source
How many times the underlying service must fail in the given window before the circuit opens.
resetTimeoutSecs :: CircuitBreakerOptions -> Int Source
The window of time in which the underlying service must fail for the circuit to open.
breakerDescription :: CircuitBreakerOptions -> String Source
Description that is attached to the failure so as to identify the particular circuit.