JavaScript implementation of the circuit breaker pattern to prevent cascading failures by managing service state transitions.
// Source: https://github.com/SynkraAI/aiox-core | License: MIT | Copyright 2025 BMad Code, LLC (BMad Method - original work) // Provided via justclaw.it.com; keep this notice with the code. 'use strict'; /** * CircuitBreaker — IDS Story IDS-5a * * Implements the Circuit Breaker pattern for graceful degradation. * Prevents cascading failures by tracking consecutive failures and * opening the circuit when a threshold is reached. * * States: * CLOSED -> Normal operation, requests pass through * OPEN -> Failures exceeded threshold, requests short-circuit * HALF_OPEN -> After reset timeout, allows one probe request * * Source: ids-principles.md circuit_breaker config */ const STATE_CLOSED = 'CLOSED'; const STATE_OPEN = 'OPEN'; const STATE_HALF_OPEN = 'HALF_OPEN'; cons ... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key