Skip to content

feat: process GitHub api with limits#47

Merged
juev merged 6 commits intomainfrom
feature/limits
Apr 29, 2025
Merged

feat: process GitHub api with limits#47
juev merged 6 commits intomainfrom
feature/limits

Conversation

@juev
Copy link
Copy Markdown
Owner

@juev juev commented Apr 27, 2025

related: #46

juev added 2 commits April 27, 2025 16:44
Refactor GitHub client to improve concurrency and rate limiting

- Replaced `conc.WaitGroup` with `sync.WaitGroup` for better compatibility.
- Added rate-limiting logic to handle GitHub API rate limits.
- Introduced a channel to limit concurrent requests to 50.
- Updated `go-github` library to v71 and adjusted imports.
- Updated dependencies in `go.mod` and `go.sum` to latest versions.
```
Refactor GitHub API calls to use a goroutine pool

Replaced custom concurrency management with a pool from the
sourcegraph/conc library to limit concurrent requests to 90.
Improved rate limit handling by logging and sleeping when limits
are exceeded. Updated dependencies in go.mod and go.sum.
```
@juev juev requested a review from Copilot April 27, 2025 19:05
@juev juev self-assigned this Apr 27, 2025
Copy link
Copy Markdown

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

This PR updates the GitHub API integration to use a newer version of go-github while adding rate-limit handling and concurrency control improvements.

  • Upgraded the GitHub API client from v58 to v71.
  • Replaced the custom concurrency management using a channel and WaitGroup with a pool-based approach.
  • Added a helper method to handle rate-limit pauses during API requests.
Files not reviewed (1)
  • go.mod: Language not supported

Comment thread github.go Outdated
Comment thread github.go Outdated
Fix typos in variable names and duration calculation
```
@juev juev requested a review from Copilot April 27, 2025 19:08
Copy link
Copy Markdown

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

This PR updates the GitHub API client and refactors the concurrency handling for retrieving starred repositories by introducing a goroutine pool with a limit, while adding support for rate limit handling.

  • Upgraded the GitHub client library from v58 to v71.
  • Replaced channel-based concurrency with a pool limiting concurrency to 90 goroutines.
  • Added a helper function (getStarredRepositories) to manage rate limits and retries.
Files not reviewed (1)
  • go.mod: Language not supported

Comment thread github.go Outdated
Comment thread github.go Outdated
juev added 3 commits April 28, 2025 08:57
- Added error handling to GetRepositories and its helper functions.
- Improved concurrency management with context and error propagation.
- Adjusted rate limit handling to avoid exceeding API limits.
@juev juev requested a review from Copilot April 28, 2025 06:17
Copy link
Copy Markdown

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

This PR enhances GitHub API processing by introducing error handling for repository retrieval and incorporating rate limit management with concurrent requests. Key changes include:

  • Modifying GetRepositories to return an error and handling it in main.go
  • Upgrading the go-github library to v71 and refactoring repository fetching to use a goroutine pool
  • Introducing a sleep-and-retry mechanism for rate limit handling in getStarredRepositories

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.

File Description
main.go Added error handling for GetRepositories and adjusted temp execution
github.go Upgraded go-github version, refactored GetRepositories, and improved rate limit handling via a pool and sleep logic
Files not reviewed (1)
  • go.mod: Language not supported
Comments suppressed due to low confidence (1)

github.go:76

  • [nitpick] The variable 'p' for the pool is very terse. Consider renaming it to a more descriptive name such as 'repoPool' to enhance code readability.
p := pool.NewWithResults[[]*github.StarredRepository]().

Comment thread github.go
@juev juev marked this pull request as ready for review April 28, 2025 06:20
@juev juev merged commit f7be27a into main Apr 29, 2025
2 checks passed
@juev juev deleted the feature/limits branch April 29, 2025 06:52
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.

2 participants