Skip to main content

CircuitBreakerOptions

Upgather Analytics


Upgather Analytics / CircuitBreakerOptions

Interface: CircuitBreakerOptions

Configuration options for circuit breaker behavior in the analytics client.

Remarks

The circuit breaker pattern prevents cascading failures by temporarily disabling requests after detecting a pattern of failures. This helps the system recover and prevents overwhelming an already struggling downstream service.

When enabled, the client will track failures and automatically "open the circuit" (stop sending requests) after exceeding the failure threshold, then automatically try again after the cooling period.

Example

import { CircuitBreakerOptions } from '@upgather/analytics';

const options: CircuitBreakerOptions = {
enabled: true,
failureThreshold: 3,
coolingPeriodMs: 15000
};

Properties

coolingPeriodMs?

optional coolingPeriodMs: number

Time in milliseconds the circuit stays open before trying again.

Remarks

Once the circuit is open, the client will wait this long before attempting to send requests again (half-open state). If the first new request succeeds, the circuit closes again. If it fails, the circuit remains open for another cooling period.

Default

30000 (30 seconds)

enabled

enabled: boolean

Whether circuit breaker protection is enabled.

Remarks

When true, the client will track failures and open the circuit after reaching the failure threshold. When false, the client will continue attempting requests regardless of previous failures.

Default

false

failureThreshold

failureThreshold: number

Number of failures before the circuit opens.

Remarks

Defines how many consecutive failures must occur before the client temporarily stops sending requests (opens the circuit).

Default

3