Add rate limit information and proactive rate limit sleep support#57
Add rate limit information and proactive rate limit sleep support#57
Conversation
- Upgrade hypersync-client dependency from 1.0.1 to 1.1.0 - Add RateLimitInfo type with limit, remaining, resetSecs, cost, retryAfterSecs, isRateLimited, and suggestedWaitSecs fields - Add QueryResponseWithRateLimit type for combined response + rate limit data - Add getWithRateLimit() method to HypersyncClient for queries with rate limit info - Add rateLimitInfo() method to get last observed rate limit state - Add waitForRateLimit() method to wait until rate limit window resets - Add proactiveRateLimitSleep config option to ClientConfig (default: true) - Bump package version from 1.1.0 to 1.2.0 - Update TypeScript type definitions (index.d.ts) https://claude.ai/code/session_012mwJv9YsuFKTvrgftATDB7
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThis PR extends the Hypersync client Rust binding with rate-limit aware APIs, adding methods to query with rate-limit information, retrieve the latest rate-limit state, and wait for rate-limit windows to reset. A configuration option for proactive rate-limit sleeping is introduced. The upstream Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| #[napi(object)] | ||
| pub struct RateLimitInfo { | ||
| /// Total request quota for the current window. | ||
| pub limit: Option<i64>, | ||
| /// Remaining budget in the current window. | ||
| pub remaining: Option<i64>, | ||
| /// Seconds until the rate limit window resets. | ||
| pub reset_secs: Option<i64>, | ||
| /// Budget consumed per request. | ||
| pub cost: Option<i64>, | ||
| /// Seconds to wait before retrying (from retry-after header). | ||
| pub retry_after_secs: Option<i64>, | ||
| /// Whether the rate limit quota has been exhausted. | ||
| pub is_rate_limited: bool, | ||
| /// Suggested number of seconds to wait before making another request. | ||
| pub suggested_wait_secs: Option<i64>, | ||
| } |
There was a problem hiding this comment.
I need to remind myself and look at the rust client, but the rust client knows the timestamp of its last request also after we spoke? Just want to understand that, otherwise this is looking good!
Summary
This PR adds comprehensive rate limit handling to the HyperSync client, including new APIs to query rate limit information and a configuration option for proactive rate limit management.
Key Changes
RateLimitInfostruct: Exposes rate limit details from server response headers including limit, remaining quota, reset time, cost per request, retry-after header, and suggested wait timeQueryResponseWithRateLimitstruct: Wraps query responses with associated rate limit informationget_with_rate_limit()method: Allows queries to retrieve both response data and rate limit info in a single callrate_limit_info()method: Returns the most recently observed rate limit information from any prior requestwait_for_rate_limit()method: Async utility to wait until the current rate limit window resetsproactive_rate_limit_sleepconfig option: Enables proactive sleeping when rate limit is exhausted instead of sending requests that would be rejected with 429 status (defaults to true)Implementation Details
RateLimitInfois converted from the underlyinghypersync_client::RateLimitInfotype with proper casting of numeric values to i64is_rate_limitedfield is computed via theis_rate_limited()method on the underlying typesuggested_wait_secsfield is computed via thesuggested_wait_secs()method on the underlying type#[napi]macro for Node.js interoperabilityhypersync-clientdependency to version 1.1.0 to support the new rate limit functionalityhttps://claude.ai/code/session_012mwJv9YsuFKTvrgftATDB7
Summary by CodeRabbit
Release Notes
New Features