Std.Breaker
Std.Breaker — a circuit breaker for calls to another service (a port).
Types
type State = Closed | Open { untilMs : Int } | HalfOpen
type alias Settings = { failures : Int , windowMs : Int , openForMs : Int , halfOpenProbes : Int }
type Mode
type Decision
type alias Cell = { mode : Mode , decision : Decision }
type Breaker
type Outcome
Values
call : Breaker -> Task Error a -> Task Error a
`call breaker task` — run `task` through the breaker. Closed: the task
callCounting : (Error -> Bool) -> Breaker -> Task Error a -> Task Error a
`callCounting counts breaker task` — `call`, with your own rule for
defaults : Settings
5 failures within 10 000 ms open the breaker for 30 000 ms, then 1 trial
isOpenRefusal : Error -> Bool
True for the error a breaker returns when it refuses a call (domain
name : Breaker -> String
The name the breaker was made with.
new : String -> Settings -> Task Error Breaker
`new name settings` — a closed breaker. The name goes into the refusal
reset : Breaker -> Task Error ()
Close the breaker and forget its failures (an operator's override).
state : Breaker -> Task Error State
The breaker's state now. An open breaker whose time is up reads as