CircuitBreaker
CircuitBreaker:
object
Defined in: Core/CircuitBreaker.ts:39
Type Declaration
Section titled “Type Declaration”is:
object
Type guards for checking circuit breaker states and errors.
is.closed
Section titled “is.closed”closed: (
state) =>state is ClosedState=isClosedState
Checks whether a circuit breaker state is Closed.
Parameters
Section titled “Parameters”State<unknown>
Returns
Section titled “Returns”state is ClosedState
- CircuitBreaker.is.open for checking if the circuit is tripped Open.
- CircuitBreaker.is.halfOpen for checking if the circuit is in trial recovery HalfOpen.
Example
Section titled “Example”is.halfOpen
Section titled “is.halfOpen”halfOpen: (
state) =>state is HalfOpenState=isHalfOpenState
Checks whether a circuit breaker state is HalfOpen.
Parameters
Section titled “Parameters”State<unknown>
Returns
Section titled “Returns”state is HalfOpenState
- CircuitBreaker.is.closed for checking if the circuit is healthy Closed.
- CircuitBreaker.is.open for checking if the circuit is tripped Open.
Example
Section titled “Example”is.open
Section titled “is.open”open: <
E>(state) =>state is OpenState<E>=isOpenState
Checks whether a circuit breaker state is Open.
Type Parameters
Section titled “Type Parameters”E = unknown
Parameters
Section titled “Parameters”State<E>
Returns
Section titled “Returns”state is OpenState<E>
- CircuitBreaker.is.closed for checking if the circuit is healthy Closed.
- CircuitBreaker.is.halfOpen for checking if the circuit is in trial recovery HalfOpen.
Example
Section titled “Example”is.openError
Section titled “is.openError”openError: <
E>(value) =>value is OpenError<E>=isCircuitOpenError
Checks whether a value is a CircuitOpenError.
Type Parameters
Section titled “Type Parameters”E = unknown
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”value is OpenError<E>
Example
Section titled “Example”make: <
E>(config) =>CircuitBreaker<E> =makeCircuitBreaker
Creates a stateful CircuitBreaker with the provided configuration options.
Type Parameters
Section titled “Type Parameters”E = unknown
Parameters
Section titled “Parameters”config
Section titled “config”Config<E>