Skip to content

feat: Circuit breaker for failing domains #53

@Snider

Description

@Snider

Summary

Stop hammering domains that are consistently failing.

Use Case

If a domain returns 5 errors in a row, stop trying for a while instead of wasting time and bandwidth.

Circuit States

CLOSED → OPEN → HALF-OPEN → CLOSED
  │        │        │
  │        │        └─ Test request succeeds
  │        └─ After cooldown period
  └─ Failure threshold exceeded

Behaviour

  • CLOSED: Normal operation, requests flow through
  • OPEN: All requests fail immediately, no network calls
  • HALF-OPEN: Allow one test request to check recovery

Commands

# Enable circuit breaker (default)
borg collect website https://example.com

# Disable
borg collect website https://example.com --no-circuit-breaker

# Custom thresholds
borg collect website https://example.com \
  --circuit-failures 3 \
  --circuit-cooldown 60s

Configuration

circuit_breaker:
  failure_threshold: 5      # failures before opening
  success_threshold: 2      # successes to close
  cooldown: 30s             # time in open state
  half_open_requests: 1     # test requests in half-open

Logging

[WARN] Circuit OPEN for api.github.com (5 consecutive failures)
[INFO] Circuit HALF-OPEN for api.github.com (testing recovery)
[INFO] Circuit CLOSED for api.github.com (recovered)

Acceptance Criteria

  • Three-state circuit breaker
  • Per-domain tracking
  • Configurable thresholds
  • Automatic recovery testing
  • Clear logging of state changes

Metadata

Metadata

Assignees

No one assigned

    Labels

    julesFor Jules AI to work on

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions