A Go (Golang) package for handling rate limiting.
To install hq-go-limiter
, run:
go get -v -u github.com/hueristiq/hq-go-limiter
Make sure your Go environment is set up properly (Go 1.x or later is recommended).
package main
import (
"fmt"
hqgolimiter "github.com/hueristiq/hq-go-limiter"
)
func main() {
options := &hqgolimiter.Options{
RequestsPerMinute: 40,
MinimumDelayInSeconds: 2,
}
ltr := hqgolimiter.New(options)
// Make 10 requests and ensure that they are rate limited.
for i := 1; i <= 10; i++ {
ltr.Wait()
fmt.Printf("Request %d made at %v\n", i, time.Now())
}
}
Contributions are welcome and encouraged! Feel free to submit Pull Requests or report Issues. For more details, check out the contribution guidelines.
A big thank you to all the contributors for your ongoing support!
This package is licensed under the MIT license. You are free to use, modify, and distribute it, as long as you follow the terms of the license. You can find the full license text in the repository - Full MIT license text.