Skip to content

Commit 9d37f8c

Browse files
authored
Merge pull request #34 from gofri/gofri/v2_release
V2 release fixes (go mod)
2 parents 1d29d19 + c635f80 commit 9d37f8c

File tree

10 files changed

+29
-31
lines changed

10 files changed

+29
-31
lines changed

README.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,31 @@
22

33
[![Go Report Card](https://goreportcard.com/badge/github.com/gofri/go-github-ratelimit)](https://goreportcard.com/report/github.com/gofri/go-github-ratelimit)
44

5-
Package `go-github-ratelimit` provides http.RoundTripper implementation that handles both [primary rate limit](https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api?#about-primary-rate-limits) and [secondary rate limit](https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api?#about-secondary-rate-limits) for the GitHub API.
5+
Package `go-github-ratelimit` providesa middleware (http.RoundTripper) that handles both [Primary Rate Limit](https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api?#about-primary-rate-limits) and [Secondary Rate Limit](https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api?#about-secondary-rate-limits) for the GitHub API.
66

7-
Primary rate limits are handled by returning a detailed error.
8-
Secondary rate limits are handled by waiting in blocking mode (sleep) and then issuing/retrying requests.
9-
There is support for callbacks to be triggered when rate limits are detected/exceeded/etc. - see below.
7+
* Primary rate limits are handled by returning a detailed error.
8+
* Secondary rate limits are handled by waiting in blocking mode (sleep) and then issuing/retrying requests.
9+
* There is support for callbacks to be triggered when rate limits are detected/exceeded/etc. - see below.
1010

11-
`go-github-ratelimit` can be used with any HTTP client communicating with GitHub API.
12-
It is meant to complement [go-github](https://github.com/google/go-github), but there is no association between this repository and the go-github repository nor Google.
13-
14-
If you like this package, please check out [go-github-pagination!](https://github.com/gofri/go-github-pagination)
11+
The module can be used with any HTTP client communicating with GitHub API. It is designed to have low overhead during good path.
12+
It is meant to complement [go-github](https://github.com/google/go-github), but there is no association between this repository and the go-github repository nor Google.
1513

1614
## Recommended: Pagination Handling
1715

18-
If you like this package, please checkout [go-github-pagination](https://github.com/gofri/go-github-pagination).
16+
If you like this package, please check out [go-github-pagination](https://github.com/gofri/go-github-pagination).
1917
It supports pagination out of the box, and plays well with the rate limit round-tripper.
2018
It is best to stack the pagination round-tripper on top of the rate limit round-tripper.
2119

2220

2321
## Installation
2422

25-
```go get github.com/gofri/go-github-ratelimit```
23+
```go get github.com/gofri/go-github-ratelimit/v2```
2624

2725
## Usage Example (with [go-github](https://github.com/google/go-github))
2826

2927
```go
3028
import "github.com/google/go-github/v68/github"
31-
import "github.com/gofri/go-github-ratelimit/github_ratelimit"
29+
import "github.com/gofri/go-github-ratelimit/v2/github_ratelimit"
3230

3331
func main() {
3432
// use the plain ratelimiter, without options / callbacks / underlying http.RoundTripper.
@@ -76,7 +74,7 @@ as well as fine-grained policy control (e.g., for a sophisticated pagination mec
7674

7775
```go
7876
import "github.com/google/go-github/v68/github"
79-
import "github.com/gofri/go-github-ratelimit/github_ratelimit"
77+
import "github.com/gofri/go-github-ratelimit/v2/github_ratelimit"
8078
import "github.com/gofri/go-github-pagination/githubpagination"
8179

8280
func main() {

e2e_test/e2e_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import (
99
"testing"
1010
"time"
1111

12-
"github.com/gofri/go-github-ratelimit/github_ratelimit/github_ratelimit_test"
13-
"github.com/gofri/go-github-ratelimit/github_ratelimit/github_secondary_ratelimit"
12+
"github.com/gofri/go-github-ratelimit/v2/github_ratelimit/github_ratelimit_test"
13+
"github.com/gofri/go-github-ratelimit/v2/github_ratelimit/github_secondary_ratelimit"
1414
"github.com/google/go-github/v64/github"
1515
)
1616

github_ratelimit/combined_ratelimit_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import (
55
"testing"
66
"time"
77

8-
"github.com/gofri/go-github-ratelimit/github_ratelimit/github_primary_ratelimit"
9-
"github.com/gofri/go-github-ratelimit/github_ratelimit/github_ratelimit_test"
10-
"github.com/gofri/go-github-ratelimit/github_ratelimit/github_secondary_ratelimit"
8+
"github.com/gofri/go-github-ratelimit/v2/github_ratelimit/github_primary_ratelimit"
9+
"github.com/gofri/go-github-ratelimit/v2/github_ratelimit/github_ratelimit_test"
10+
"github.com/gofri/go-github-ratelimit/v2/github_ratelimit/github_secondary_ratelimit"
1111
)
1212

1313
func TestCombinedRateLimiter(t *testing.T) {

github_ratelimit/github_ratelimit_test/ratelimit_injecter.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import (
1111
"sync"
1212
"time"
1313

14-
"github.com/gofri/go-github-ratelimit/github_ratelimit/github_primary_ratelimit"
15-
"github.com/gofri/go-github-ratelimit/github_ratelimit/github_secondary_ratelimit"
16-
github_ratelimit "github.com/gofri/go-github-ratelimit/github_ratelimit/github_secondary_ratelimit"
14+
"github.com/gofri/go-github-ratelimit/v2/github_ratelimit/github_primary_ratelimit"
15+
"github.com/gofri/go-github-ratelimit/v2/github_ratelimit/github_secondary_ratelimit"
16+
github_ratelimit "github.com/gofri/go-github-ratelimit/v2/github_ratelimit/github_secondary_ratelimit"
1717
)
1818

1919
const (

github_ratelimit/github_ratelimit_test/test_utils.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88
"testing"
99
"time"
1010

11-
"github.com/gofri/go-github-ratelimit/github_ratelimit/github_primary_ratelimit"
12-
"github.com/gofri/go-github-ratelimit/github_ratelimit/github_secondary_ratelimit"
11+
"github.com/gofri/go-github-ratelimit/v2/github_ratelimit/github_primary_ratelimit"
12+
"github.com/gofri/go-github-ratelimit/v2/github_ratelimit/github_secondary_ratelimit"
1313
)
1414

1515
func NewSecondaryClient(base http.RoundTripper, opts ...github_secondary_ratelimit.Option) *http.Client {

github_ratelimit/github_ratelimiter.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"fmt"
66
"net/http"
77

8-
"github.com/gofri/go-github-ratelimit/github_ratelimit/github_primary_ratelimit"
9-
"github.com/gofri/go-github-ratelimit/github_ratelimit/github_secondary_ratelimit"
8+
"github.com/gofri/go-github-ratelimit/v2/github_ratelimit/github_primary_ratelimit"
9+
"github.com/gofri/go-github-ratelimit/v2/github_ratelimit/github_secondary_ratelimit"
1010
)
1111

1212
type PrimaryRateLimiter = github_primary_ratelimit.PrimaryRateLimiter

github_ratelimit/github_secondary_ratelimit/secondary_rate_limit.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,13 @@ func (t *SecondaryRateLimiter) currentSleepDurationUnlocked() time.Duration {
139139
return time.Until(*t.resetTime)
140140
}
141141

142-
func (t *SecondaryRateLimiter) triggerCallback(callback func(*CallbackContext), callbackContext *CallbackContext, newSleepUntil time.Time) {
142+
func (t *SecondaryRateLimiter) triggerCallback(callback func(*CallbackContext), callbackContext *CallbackContext, newResetTime time.Time) {
143143
if callback == nil {
144144
return
145145
}
146146

147147
callbackContext.RoundTripper = t
148-
callbackContext.ResetTime = &newSleepUntil
148+
callbackContext.ResetTime = &newResetTime
149149
callbackContext.TotalSleepTime = &t.totalSleepTime
150150

151151
callback(callbackContext)

github_ratelimit/primary_ratelimit_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import (
1010
"testing"
1111
"time"
1212

13-
"github.com/gofri/go-github-ratelimit/github_ratelimit/github_primary_ratelimit"
14-
"github.com/gofri/go-github-ratelimit/github_ratelimit/github_ratelimit_test"
13+
"github.com/gofri/go-github-ratelimit/v2/github_ratelimit/github_primary_ratelimit"
14+
"github.com/gofri/go-github-ratelimit/v2/github_ratelimit/github_ratelimit_test"
1515
)
1616

1717
var AllCategories = github_primary_ratelimit.GetAllCategories()

github_ratelimit/secondary_ratelimit_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import (
99
"testing"
1010
"time"
1111

12-
"github.com/gofri/go-github-ratelimit/github_ratelimit/github_ratelimit_test"
13-
"github.com/gofri/go-github-ratelimit/github_ratelimit/github_secondary_ratelimit"
12+
"github.com/gofri/go-github-ratelimit/v2/github_ratelimit/github_ratelimit_test"
13+
"github.com/gofri/go-github-ratelimit/v2/github_ratelimit/github_secondary_ratelimit"
1414
)
1515

1616
func TestSecondaryRateLimit(t *testing.T) {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
module github.com/gofri/go-github-ratelimit
1+
module github.com/gofri/go-github-ratelimit/v2
22

33
go 1.23.1

0 commit comments

Comments
 (0)