Skip to content

Handle rate limit headers in client, adjust request throttling#61

Merged
piceri merged 7 commits intomainfrom
client-rate-limit
Mar 20, 2026
Merged

Handle rate limit headers in client, adjust request throttling#61
piceri merged 7 commits intomainfrom
client-rate-limit

Conversation

@piceri
Copy link
Contributor

@piceri piceri commented Mar 19, 2026

This request:

  • Adjusts client to respect rate limit headers from the GitHub API
    • Retry-After and X-Ratelimit-Reset headers are both checked, largest delay is applied
    • Rate limit delays are shared by all workers
  • Renamed existing rateLimiter to requestThrottler and lowered throughput to 180 requests/min
  • Add User-Agent to client request to quickly distinguish Deployment Tracker requests,

piceri added 5 commits March 18, 2026 16:52
…vided in headers

Signed-off-by: Eric Pickard <piceri@github.com>
Signed-off-by: Eric Pickard <piceri@github.com>
Signed-off-by: Eric Pickard <piceri@github.com>
… limits to match github secondary rate limits

Signed-off-by: Eric Pickard <piceri@github.com>
Signed-off-by: Eric Pickard <piceri@github.com>
@piceri piceri marked this pull request as ready for review March 19, 2026 21:07
@piceri piceri requested a review from a team as a code owner March 19, 2026 21:07
Copilot AI review requested due to automatic review settings March 19, 2026 21:07
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the deployment record client to better handle GitHub API rate limiting by deriving a shared backoff from response headers and applying a renamed/request throttling mechanism across workers.

Changes:

  • Add shared, cross-goroutine rate-limit backoff based on Retry-After and X-Ratelimit-Reset headers.
  • Rename rateLimiter to requestThrottler and adjust the default throughput configuration.
  • Add User-Agent header and extend tests to cover rate-limit delay parsing and cross-goroutine behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
pkg/deploymentrecord/client.go Implements server-driven backoff using rate-limit headers, renames/throttles request limiter, and adds a User-Agent.
pkg/deploymentrecord/client_test.go Updates existing rate-limit tests and adds new unit/concurrency tests for rate-limit delay parsing and shared backoff behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: Eric Pickard <piceri@github.com>
ajbeattie
ajbeattie previously approved these changes Mar 19, 2026
Copy link

@ajbeattie ajbeattie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, with a +1 on the Copilot comment about either removing the max 60 second Retry After or adding a note explaining it.

Signed-off-by: Eric Pickard <piceri@github.com>
@piceri
Copy link
Contributor Author

piceri commented Mar 20, 2026

LGTM, with a +1 on the Copilot comment about either removing the max 60 second Retry After or adding a note explaining it.

Thanks! Removed the check, secondary rate limits should reset every min but it should be good enough to trust the header value.

@piceri piceri merged commit 361af00 into main Mar 20, 2026
6 checks passed
@piceri piceri deleted the client-rate-limit branch March 20, 2026 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants