Add non-retrying rate limit API and improve rate limit handling#130
Add non-retrying rate limit API and improve rate limit handling#130DZakh wants to merge 9 commits into
Conversation
Callers using get_arrow_with_rate_limit and get_with_rate_limit manage rate limiting externally and may issue long-running queries, so the default HTTP request timeout should not apply to them. Thread a use_timeout flag through the internal call chain and disable the timeout for these two public methods while preserving it for all other paths. Co-authored-by: claude <noreply@anthropic.com>
…mediately The _with_rate_limit public methods are designed for callers that manage rate limiting externally. Previously a 429 response would trigger internal retry + sleep logic, hiding the rate limit signal from the caller. Now get_arrow_with_rate_limit and get_with_rate_limit return a HyperSyncResponseError::RateLimited error immediately on 429 so callers can implement their own back-off. All other error types are still retried normally, and the HTTP timeout is preserved. Co-authored-by: claude <noreply@anthropic.com>
Co-authored-by: claude <noreply@anthropic.com>
…_rate_limit methods When retry_on_rate_limit is false, the proactive rate-limit check now returns a HyperSyncResponseError::RateLimited error instead of sleeping until the window resets. Extracted the rate-limit state check into get_proactive_rate_limit_info() and reused it in wait_for_rate_limit(). Co-authored-by: claude <noreply@anthropic.com>
Introduce a RateLimitResponse<T> enum with Success and RateLimited variants so callers can pattern-match on 429 directly instead of downcasting anyhow errors. The _with_rate_limit methods now return Result<RateLimitResponse<T>> where the RateLimited variant carries the RateLimitInfo and the Success variant carries both the response and rate limit headers. Co-authored-by: claude <noreply@anthropic.com>
Co-authored-by: claude <noreply@anthropic.com>
Co-authored-by: claude <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe PR refactors rate-limit response handling in the Rust HyperSync client by replacing the ChangesRate-Limit Response Type and API Refactor
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
Comment |
Co-authored-by: claude <noreply@anthropic.com>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
hypersync-client/Cargo.toml (1)
1-3: 💤 Low valueConsider whether this should be a major version bump (2.0.0).
The return type of
get_arrow_with_rate_limitandget_with_rate_limitchanged fromQueryResponseWithRateLimittoRateLimitResponse. Under semantic versioning for versions ≥1.0.0, changing public API return types is a breaking change that typically warrants a major version bump.If existing consumers are few or the
_with_rate_limitmethods are rarely used externally, a minor bump may be acceptable as a pragmatic choice—but it's worth confirming this aligns with the project's versioning policy.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@hypersync-client/Cargo.toml` around lines 1 - 3, This change alters the public return types of get_arrow_with_rate_limit and get_with_rate_limit from QueryResponseWithRateLimit to RateLimitResponse which is a breaking API change; decide whether to bump the crate to 2.0.0 under semver, and if so update the version field in Cargo.toml to "2.0.0", add a clear entry in CHANGELOG.md noting the breaking change (mentioning get_arrow_with_rate_limit, get_with_rate_limit, QueryResponseWithRateLimit -> RateLimitResponse), and update any README or compatibility notes; if you opt not to major-bump, document why (few/no external consumers) in the changelog and consider adding adapter functions or a deprecation plan to avoid surprising users.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@hypersync-client/Cargo.toml`:
- Around line 1-3: This change alters the public return types of
get_arrow_with_rate_limit and get_with_rate_limit from
QueryResponseWithRateLimit to RateLimitResponse which is a breaking API change;
decide whether to bump the crate to 2.0.0 under semver, and if so update the
version field in Cargo.toml to "2.0.0", add a clear entry in CHANGELOG.md noting
the breaking change (mentioning get_arrow_with_rate_limit, get_with_rate_limit,
QueryResponseWithRateLimit -> RateLimitResponse), and update any README or
compatibility notes; if you opt not to major-bump, document why (few/no external
consumers) in the changelog and consider adding adapter functions or a
deprecation plan to avoid surprising users.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c52503a7-8c56-4c0e-ab08-a3d80eb03da3
📒 Files selected for processing (4)
hypersync-client/Cargo.tomlhypersync-client/src/lib.rshypersync-client/src/stream.rshypersync-client/src/types.rs
Mirrors get_events but returns RateLimitResponse so callers can handle 429 responses externally, consistent with the other _with_rate_limit methods. Co-authored-by: claude <noreply@anthropic.com>
Summary
This PR introduces a new
RateLimitResponseenum to provide callers with explicit control over rate limit handling. Theget_with_rate_limitandget_arrow_with_rate_limitmethods now return immediately on HTTP 429 responses instead of retrying internally, allowing applications to implement their own back-off strategies.Key Changes
New
RateLimitResponseenum: ReplacesQueryResponseWithRateLimitstruct with an enum that distinguishes between successful responses and rate-limited responsesSuccess { response, rate_limit }: Query succeeded with rate limit infoRateLimited(RateLimitInfo): Server returned HTTP 429 (no internal retry)Rate limit API improvements:
get_arrow_with_size()now accepts aretry_on_rate_limitparameter to control retry behaviorget_arrow_with_rate_limit()andget_with_rate_limit()no longer retry on 429 responsesget_proactive_rate_limit_info()helper method to check if client is rate-limited without waitingretry_on_rate_limitflagDocumentation improvements:
get_with_rate_limitandget_arrow_with_rate_limitto clarify non-retrying behaviorURL updates: Updated Envio plan upgrade URLs from
https://app.envio.dev/api-tokenstohttps://envio.dev/app/api-tokensin error messages and logsVersion bump: Updated to 1.2.0 to reflect the API changes
Implementation Details
get_arrow_with_size()method now conditionally applies proactive rate limiting based on theretry_on_rate_limitflagretry_on_rate_limit=false, rate limit errors are returned immediately instead of being caught and retriedwait_for_rate_limit()method was refactored to use the newget_proactive_rate_limit_info()helper, reducing code duplicationhttps://claude.ai/code/session_01V1sz4C6ukyDDdaLPtk2vgi
Summary by CodeRabbit
New Features
Chores