feat(client): opt-in retry with backoff honoring Retry-After#58
Merged
Conversation
Implements plans/refactor/07-retry-support.md (final ticket):
- RetryConfig frozen dataclass (max_retries=0, backoff_factor=0.5,
retry_statuses={429,502,503,504}, retry_methods={GET,HEAD,PUT,DELETE}),
exported from the top-level package and accepted by
CodesphereSDK(retry=...)
- Retry loop in APIHttpClient.request: idempotent methods only by
default (POST opt-in via retry_methods), retries on the configured
statuses and on httpx timeout/connect errors; delay honors Retry-After
(delta-seconds or HTTP-date, past dates clamp to 0) and falls back to
exponential backoff with jitter; exhausted retries raise exactly what
the non-retry path would (RateLimitError with retry_after populated,
TimeoutError, ...); each retry is logged at debug level
- Plain ~40-line loop, no retry dependency reintroduced
- Default max_retries=0 means zero behavior change unless opted in
(tested: single request on failure with the default config)
- 17 respx tests: Retry-After honored (429->200 with exactly 2 requests
and >=1s sleep), exhaustion, exponential backoff bounds, non-retryable
500, POST gating and opt-in, transport-error retries, SDK wire-through,
Retry-After parsing matrix
- README documents RetryConfig
🛡️ Bandit Security Scan Results✅ No security issues found by Bandit. |
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.
Implements plans/refactor/07-retry-support.md (final ticket):