Safe Haskell | Safe |
---|---|
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.
Synopsis
- data CircuitBreakerOptions
- data CircuitBreakerState
- data CircuitBreakerException = CircuitBreakerException String
- combineCircuitBreakerStates :: Foldable t => t CircuitBreakerState -> CircuitBreakerState
- isCircuitBreakerOpen :: MonadBaseControl IO m => CircuitBreakerState -> m Bool
- isCircuitBreakerClosed :: MonadBaseControl IO m => CircuitBreakerState -> m Bool
- defaultCircuitBreakerOptions :: CircuitBreakerOptions
- circuitBreaker :: (MonadBaseControl IO m, MonadBaseControl IO n) => CircuitBreakerOptions -> BasicService m a b -> n (CircuitBreakerState, 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 CircuitBreakerState Source #
Representation of the state the circuit breaker is currently in.
data CircuitBreakerException Source #
Exception thrown when the circuit is open.
Instances
Eq CircuitBreakerException Source # | |
Defined in Glue.CircuitBreaker | |
Show CircuitBreakerException Source # | |
Defined in Glue.CircuitBreaker showsPrec :: Int -> CircuitBreakerException -> ShowS # show :: CircuitBreakerException -> String # showList :: [CircuitBreakerException] -> ShowS # | |
Exception CircuitBreakerException Source # | |
combineCircuitBreakerStates :: Foldable t => t CircuitBreakerState -> CircuitBreakerState Source #
Combines multiple states together.
isCircuitBreakerOpen :: MonadBaseControl IO m => CircuitBreakerState -> m Bool Source #
Determines if a circuit breaker is open.
isCircuitBreakerClosed :: MonadBaseControl IO m => CircuitBreakerState -> m Bool Source #
Determines if a circuit breaker is closed.
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 (CircuitBreakerState, 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.