glue-core-0.6.3: Make better services and clients.

Safe HaskellSafe
LanguageHaskell2010

Glue.CircuitBreaker

Description

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

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.

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.

circuitBreaker Source #

Arguments

:: (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.