glue-core-0.4.0: Make better services.

Safe HaskellNone



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 Source

Options for determining behaviour of circuit breaking services.

data CircuitBreakerStatus Source

Status indicating if the circuit is open.

defaultCircuitBreakerOptions :: CircuitBreakerOptions Source

Defaulted options for the circuit breaker with 3 failures over 60 seconds.

circuitBreaker Source


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