Skip to main content
Dotset CLI API Documentation / index / CircuitBreakerOptions

Interface: CircuitBreakerOptions

Defined in: src/mantle/errors/index.ts:712 Error Handling and Recovery Module Comprehensive error handling with retry logic and circuit breakers.

Example

import {
  withRetry,
  withTimeout,
  CircuitBreaker,
  isRetryableError,
} from '@dotsetlabs/cli';

// Retry with exponential backoff
const result = await withRetry(
  () => fetchSecrets(),
  { maxAttempts: 3, baseDelayMs: 1000, backoffMultiplier: 2 }
);

// Add timeout to operation
const secrets = await withTimeout(fetchSecrets(), 5000);

// Use circuit breaker for external services
const breaker = new CircuitBreaker('aws-sm', {
  failureThreshold: 5,
  resetTimeoutMs: 30000,
});

const secret = await breaker.execute(() => getFromAWS(key));

Properties

failureThreshold?

optional failureThreshold: number;
Defined in: src/mantle/errors/index.ts:713

halfOpenMaxCalls?

optional halfOpenMaxCalls: number;
Defined in: src/mantle/errors/index.ts:716

onFailure()?

optional onFailure: (name, error) => void;
Defined in: src/mantle/errors/index.ts:722

Parameters

name
string
error

Returns

void

onStateChange()?

optional onStateChange: (name, from, to) => void;
Defined in: src/mantle/errors/index.ts:717

Parameters

name
string
from
to

Returns

void

onSuccess()?

optional onSuccess: (name) => void;
Defined in: src/mantle/errors/index.ts:723

Parameters

name
string

Returns

void

resetTimeoutMs?

optional resetTimeoutMs: number;
Defined in: src/mantle/errors/index.ts:715

successThreshold?

optional successThreshold: number;
Defined in: src/mantle/errors/index.ts:714