Currently in the documentation, a proposed rate limit function is provided as such:
func rateLimitCallback(lastResponse *helix.Response) error {
if lastResponse.GetRateLimitRemaining() > 0 {
return nil
}
var reset64 int64
reset64 = int64(lastResponse.GetRateLimitReset())
currentTime := time.Now().Unix()
if currentTime < reset64 {
timeDiff := time.Duration(reset64 - currentTime)
if timeDiff > 0 {
fmt.Printf("Waiting on rate limit to pass before sending next request (%d seconds)\n", timeDiff)
time.Sleep(timeDiff * time.Second)
}
}
return nil
}
I propose adding this function, sans the print statement, to the core helix library. The user would still have to specify the use of this function, but it would simplify the usage of this library and reduce boiler plate for the end user. As such, a client might instantiate the client like so:
Currently in the documentation, a proposed rate limit function is provided as such:
I propose adding this function, sans the print statement, to the core helix library. The user would still have to specify the use of this function, but it would simplify the usage of this library and reduce boiler plate for the end user. As such, a client might instantiate the client like so:
where
helix.DefaultRateLimit
is the example function above.Thoughts?