Skip to content

Commit

Permalink
Merge pull request #1837 from marwatk/min-burst
Browse files Browse the repository at this point in the history
Place a floor of 1 on the rate limit burst to prevent x/time from throwing an error
  • Loading branch information
svanharmelen committed Nov 15, 2023
2 parents 793bc3c + a449e2b commit 3e35f87
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,11 @@ func (c *Client) configureLimiter(ctx context.Context, headers http.Header) {
limit := rate.Limit(rateLimit * 0.66)
burst := int(rateLimit * 0.33)

// Need at least one allowed to burst or x/time will throw an error
if burst == 0 {
burst = 1
}

// Create a new limiter using the calculated values.
c.limiter = rate.NewLimiter(limit, burst)

Expand Down

0 comments on commit 3e35f87

Please sign in to comment.