HETZNER: Clean up lint warning (#2280)

Co-authored-by: Tom Limoncelli <tal@whatexit.org>
This commit is contained in:
Tom Limoncelli 2023-04-16 14:22:03 -04:00 committed by GitHub
parent 60470a3886
commit ca5ef2d4ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -237,29 +237,32 @@ func (rrl *requestRateLimiter) handleResponse(resp *http.Response) (bool, error)
// When rate-limited, exclude network/server latency from delay.
rrl.lastRequest = time.Now()
return true, nil
} else {
limit, err := parseHeaderAsInt(resp.Header, "Ratelimit-Limit", 1)
if err != nil {
return false, err
}
remaining, err := parseHeaderAsInt(resp.Header, "Ratelimit-Remaining", 1)
if err != nil {
return false, err
}
reset, err := parseHeaderAsSeconds(resp.Header, "Ratelimit-Reset", 0)
if err != nil {
return false, err
}
if remaining == 0 {
// Quota exhausted. Wait until quota resets.
rrl.delay = reset
} else if remaining > limit/2 {
// Burst through half of the quota, ...
rrl.delay = 0
} else {
// ... then spread requests evenly throughout the window.
rrl.delay = reset / time.Duration(remaining+1)
}
return false, nil
}
limit, err := parseHeaderAsInt(resp.Header, "Ratelimit-Limit", 1)
if err != nil {
return false, err
}
remaining, err := parseHeaderAsInt(resp.Header, "Ratelimit-Remaining", 1)
if err != nil {
return false, err
}
reset, err := parseHeaderAsSeconds(resp.Header, "Ratelimit-Reset", 0)
if err != nil {
return false, err
}
if remaining == 0 {
// Quota exhausted. Wait until quota resets.
rrl.delay = reset
} else if remaining > limit/2 {
// Burst through half of the quota, ...
rrl.delay = 0
} else {
// ... then spread requests evenly throughout the window.
rrl.delay = reset / time.Duration(remaining+1)
}
return false, nil
}