Improve mirror resilience, selection, and reduce boilerplate#37
Open
Improve mirror resilience, selection, and reduce boilerplate#37
Conversation
- Add retry with backoff for transient HTTP errors (429/500/502/503) - Add rate limit header awareness (x-ratelimit-remaining backpressure) - Add exponential backoff on circuit breaker cooldown (30s → 10min cap) - Add failure rate EMA to mirror health, use composite score for ordering - Add async wait_for_availability() in sequential fallback path - Extract common _fetch() base method, reducing ~220 lines of duplication - Add response size limits (100MB) for .osz downloads - Remove unused get_mirror_weight/BeatmapMirrorScore dead code Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_fetch()retries 429/500/502/503 and network exceptions once with 1s backoffx-ratelimit-remainingfrom upstream responses and drains the token bucket when remaining < 10, preventing rate limit tripsfailure_ematoMirrorHealthand ascore()method that penalizes unreliable mirrors (latency * (1 + 3 * failure_rate)), so a fast-but-flaky mirror ranks below a slower reliable onewait_for_availability()briefly sleeps (up to 2s) for rate limiter token refill instead of skipping healthy-but-throttled mirrors_fetch()base method +_extra_headers()hook, reducing ~220 lines of duplicated try/except/404/451 handling across Mino, OsuDirect, and NerinyanContent-Lengthcheck before bufferingget_mirror_weight,BeatmapMirrorScore,MIRROR_INITIAL_WEIGHTwere never calledTest plan
🤖 Generated with Claude Code