Connectum API Reference / @connectum/interceptors / CircuitBreakerOptions
Interface: CircuitBreakerOptions ​
Defined in: types.ts:185
Circuit breaker interceptor options
Properties ​
failurePredicate? ​
optionalfailurePredicate?: (error,defaultPredicate) =>boolean
Defined in: types.ts:232
Decides whether an error counts as a circuit failure.
Receives the default predicate as the second argument so the default policy can be composed (extended or restricted) instead of reimplemented:
// Extend: also trip on NotFound
failurePredicate: (err, def) =>
def(err) || (err instanceof ConnectError && err.code === Code.NotFound)
// Restrict: never trip on ResourceExhausted (e.g. upstream rate limits)
failurePredicate: (err, def) =>
def(err) && !(err instanceof ConnectError && err.code === Code.ResourceExhausted)
// Legacy behavior: every error trips the breaker
failurePredicate: () => trueErrors NOT classified as failures never open or re-arm the breaker and, in half-open state, close the circuit (treated as a successful probe). A predicate that throws is treated as if it returned true (fail-closed); the original upstream error is always the one propagated to the caller.
Parameters ​
error ​
unknown
defaultPredicate ​
(error) => boolean
Returns ​
boolean
Default ​
defaultFailurePredicate (infrastructure codes only: Unknown,
DeadlineExceeded, Internal, Unavailable, DataLoss, ResourceExhausted;
non-ConnectError values count as failures)halfOpenAfter? ​
optionalhalfOpenAfter?:number
Defined in: types.ts:196
Time in milliseconds to wait before attempting to close circuit
Default ​
30000 (30 seconds)skipStreaming? ​
optionalskipStreaming?:boolean
Defined in: types.ts:202
Skip circuit breaker for streaming calls
Default ​
truethreshold? ​
optionalthreshold?:number
Defined in: types.ts:190
Number of consecutive failures before opening circuit
Default ​
5