{
 "library": "bootstrap",
 "version": "0.11.0",
 "root": "a6a3d1ff0f982ee30430c5b42f3784c8ec901fd68482cfc1bc30899c1e5e48c5",
 "license": null,
 "slug": "CircuitBreaker",
 "ref": "CircuitBreaker#3caa",
 "hash": "sema:CircuitBreaker#mh:SHA-256:3caa9c387c04bb2ac66ec35a6cfe2665e11339f0d47576b96d68229226580c76",
 "stub": "3caa",
 "layer": "Infrastructure",
 "type": "Primitives",
 "summary": "Fail-fast protection against cascading failures",
 "mechanism": "State#4f25 machine wrapper for fallible operations. Monitors failure rates of a target resource. States: (1) 'CLOSED': Requests pass normally. (2) 'OPEN': Requests fail immediately (Fail Fast) without invoking target. (3) 'HALF-OPEN': Limited trial requests allowed to test recovery. Transitions: 'CLOSED' -> 'OPEN' if failure count > threshold. 'OPEN' -> 'HALF-OPEN' after reset timeout. It wraps operations, switching to an open state on failure to prevent cascading overloads, while using Backoff#9e59 and retry logic to schedule recovery probes.",
 "invariants": [
  "Fail Fast: If State#4f25 == 'OPEN', request MUST be rejected immediately with zero backend cost.",
  "Leakage Protection: In 'HALF-OPEN' state, concurrency is capped (default: 1) to prevent flood during recovery.",
  "State#4f25 Persistence: Failure counts reset only on successful transition to 'CLOSED'."
 ],
 "parameters": [
  {
   "name": "failure_threshold",
   "type": "Integer",
   "range": "[1, 100]",
   "description": "Default: 5"
  },
  {
   "name": "half_open_limit",
   "type": "Integer",
   "range": "[1, 10]",
   "description": "Max probes allowed in half-open state"
  },
  {
   "name": "reset_timeout",
   "type": "Duration",
   "range": "unspecified",
   "description": "Default: 60s"
  }
 ],
 "signature": [],
 "preconditions": [
  "Failure threshold defined",
  "Target resource identified"
 ],
 "postconditions": [
  "Internal state updated based on outcome",
  "Request processed OR Blocked"
 ],
 "failure_modes": [
  "Flapping: Threshold too sensitive causes circuit to oscillate between Open/Closed.",
  "Zombie State#4f25: Circuit stuck 'OPEN' because reset logic failed to trigger or persists in failure.",
  "False Positive: Transient network blips trip circuit, blocking healthy traffic."
 ],
 "domain": "",
 "caution": "",
 "sources": [],
 "name": "CircuitBreaker",
 "builds_on": [
  {
   "alias": "backoff",
   "relation": "references",
   "library": "bootstrap",
   "slug": "Backoff",
   "ref": "Backoff#9e59",
   "url": "https://semahash.org/vocabularies/bootstrap/patterns/Backoff"
  },
  {
   "alias": "state",
   "relation": "references",
   "library": "bootstrap",
   "slug": "State",
   "ref": "State#4f25",
   "url": "https://semahash.org/vocabularies/bootstrap/patterns/State"
  }
 ],
 "related": [
  {
   "alias": null,
   "relation": "related",
   "library": "bootstrap",
   "slug": "StopDrill",
   "ref": "StopDrill#dcfb",
   "url": "https://semahash.org/vocabularies/bootstrap/patterns/StopDrill"
  }
 ],
 "used_by": [
  {
   "slug": "Exception",
   "relation": "references",
   "url": "https://semahash.org/vocabularies/bootstrap/patterns/Exception"
  },
  {
   "slug": "FailClosed",
   "relation": "references",
   "url": "https://semahash.org/vocabularies/bootstrap/patterns/FailClosed"
  },
  {
   "slug": "Retry",
   "relation": "references",
   "url": "https://semahash.org/vocabularies/bootstrap/patterns/Retry"
  },
  {
   "slug": "Rollout",
   "relation": "composes_with",
   "url": "https://semahash.org/vocabularies/bootstrap/patterns/Rollout"
  },
  {
   "slug": "StopDrill",
   "relation": "references",
   "url": "https://semahash.org/vocabularies/bootstrap/patterns/StopDrill"
  }
 ],
 "url": "https://semahash.org/vocabularies/bootstrap/patterns/CircuitBreaker",
 "md_url": "https://semahash.org/vocabularies/bootstrap/patterns/CircuitBreaker.md",
 "library_url": "https://semahash.org/vocabularies/bootstrap"
}
