You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Provide optional automatic handling of API rate limiting for generated clients by detecting 429 responses and standard rate limit headers, then delaying & retrying appropriately.
Motivation
APIs commonly enforce quotas; naive clients either hammer endpoints or force manual retry logic scattered throughout user code. Centralizing logic increases reliability and reduces boilerplate.
Goals
Detect rate limit signals via:
HTTP 429 status codes
Standard headers: Retry-After, X-RateLimit-Remaining, X-RateLimit-Reset, RateLimit-Remaining, RateLimit-Reset (IETF draft), and GitHub-style variants.
Compute sleep duration: prefer Retry-After (seconds or HTTP-date). Fallback to time until reset if remaining == 0.
Summary
Provide optional automatic handling of API rate limiting for generated clients by detecting 429 responses and standard rate limit headers, then delaying & retrying appropriately.
Motivation
APIs commonly enforce quotas; naive clients either hammer endpoints or force manual retry logic scattered throughout user code. Centralizing logic increases reliability and reduces boilerplate.
Goals
Retry-After,X-RateLimit-Remaining,X-RateLimit-Reset,RateLimit-Remaining,RateLimit-Reset(IETF draft), and GitHub-style variants.Retry-After(seconds or HTTP-date). Fallback to time until reset if remaining == 0.Non-Goals (initial)
Proposed Approach
APIConfigwithrate_limitsettings: enabled, max_attempts, max_total_sleep, respect_retry_after (bool), header_priority list.Retry-After(int) -> seconds.Retry-After(HTTP-date) -> parse to seconds.Telemetry / Hooks
on_rate_limited(attempt, delay, headers, method, path).Testing
Open Questions
Future Extensions
Next Steps
Related: #102 (retry strategy).