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

Type Alias: CircuitState

type CircuitState = "closed" | "open" | "half-open";
Defined in: src/mantle/errors/index.ts:710 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));