feat: wire the circuit breaker into the proxy fetch path #90

Merged
benvin merged 2 commits from benvin/wire-circuit-breaker into master 2026-07-02 22:43:23 +10:00
Owner

Fixes #74

Why

internal/proxy/circuit.go implemented and tested a circuit breaker, but nothing ever called it — a repeatedly-failing upstream was still hit on every request.

Changes

  • Construct a CircuitBreaker in NewEngine.
  • In Engine.Fetch: short-circuit when the breaker is open (serve stale from the store if present, otherwise return 503), RecordFailure on each UpstreamError, and RecordSuccess on a successful fetch.

Validation

  • go test ./internal/proxy/ and make e2e pass.
Fixes #74 ## Why `internal/proxy/circuit.go` implemented and tested a circuit breaker, but nothing ever called it — a repeatedly-failing upstream was still hit on every request. ## Changes - Construct a `CircuitBreaker` in `NewEngine`. - In `Engine.Fetch`: short-circuit when the breaker is open (serve stale from the store if present, otherwise return 503), `RecordFailure` on each `UpstreamError`, and `RecordSuccess` on a successful fetch. ## Validation - `go test ./internal/proxy/` and `make e2e` pass.
unkinben added 1 commit 2026-07-02 22:34:22 +10:00
feat: wire the circuit breaker into the proxy fetch path
ci/woodpecker/pr/test Pipeline failed
ci/woodpecker/pr/pre-commit Pipeline failed
ci/woodpecker/pr/build Pipeline failed
ad6dfbdc5b
The circuit breaker was fully implemented and tested but never called, so
a failing upstream was hit on every request. Engine.Fetch now short-
circuits when the breaker is open (serving stale if available, else 503),
records a failure on each UpstreamError, and resets on success.

Refs #74
unkinben force-pushed benvin/wire-circuit-breaker from 6d6cc4b78c to ad6dfbdc5b 2026-07-02 22:34:22 +10:00 Compare
Author
Owner

Rebased onto latest master (resolved engine.go conflicts against the batched access-log writer and the streaming/HEAD changes). Depends on #96 (master does not currently compile); verified this branch builds + passes make e2e on top of #96.

Rebased onto latest master (resolved engine.go conflicts against the batched access-log writer and the streaming/HEAD changes). Depends on #96 (master does not currently compile); verified this branch builds + passes make e2e on top of #96.
benvin added 1 commit 2026-07-02 22:36:39 +10:00
Merge branch 'master' into benvin/wire-circuit-breaker
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
ci/woodpecker/pr/build Pipeline was successful
5b079e1f79
benvin merged commit 1b585af14e into master 2026-07-02 22:43:23 +10:00
benvin deleted branch benvin/wire-circuit-breaker 2026-07-02 22:43:23 +10:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: unkin/artifactapi#90