Skip to content

Commit 3d4bf0e

Browse files
committed
fix: parsing millisecond precision time for sleeping when rate limited
1 parent dea955b commit 3d4bf0e

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

api/rate_limits.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ import (
2727
)
2828

2929
type rateLimitResponse struct {
30-
Message string `json:"message"`
31-
RetryAfter time.Duration `json:"retry_after"`
32-
Global bool `json:"global"`
30+
Message string `json:"message"`
31+
RetryAfter float64 `json:"retry_after"`
32+
Global bool `json:"global"`
3333
}
3434

3535
// customRateLimit holds information for defining a custom rate limit

api/rest.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ func (r *RateLimiter) lockedRequest(method, route, contentType string, b interfa
137137
return nil, err
138138
}
139139

140-
time.Sleep(rlr.RetryAfter)
140+
time.Sleep(time.Duration(rlr.RetryAfter * float64(time.Second)))
141141

142142
return r.lockedRequest(method, route, contentType, b, r.lockBucketObject(bucket), sequence, reason)
143143
}

0 commit comments

Comments
 (0)