Skip to content

Commit

Permalink
Skip using rate limit info if it doesn't make sense. (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
ggreer authored Sep 13, 2024
1 parent 79bbf3e commit 623c8f0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/sync/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,19 @@ func shouldWaitAndRetry(ctx context.Context, err error) bool {
for _, detail := range details {
if rlData, ok := detail.(*v2.RateLimitDescription); ok {
waitResetAt := time.Until(rlData.ResetAt.AsTime())
if waitResetAt <= 0 {
continue
}
duration := time.Duration(rlData.Limit)
if duration == 0 {
duration = 1
if duration <= 0 {
continue
}
waitResetAt /= duration
// Round up to the nearest second to make sure we don't hit the rate limit again
waitResetAt = time.Duration(math.Ceil(waitResetAt.Seconds())) * time.Second
if waitResetAt > 0 {
wait = waitResetAt
break
}
}
}
Expand Down

0 comments on commit 623c8f0

Please sign in to comment.