A Go(Golang) package for handling rate limiting.
go get -v -u go.source.hueristiq.com/limiter
Here's a simple example demonstrating how to use hq-go-limiter
:
package main
import (
"fmt"
"go.source.hueristiq.com/limiter"
)
func main() {
options := &limiter.Options{
RequestsPerMinute: 40,
MinimumDelayInSeconds: 2,
}
ltr := limiter.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())
}
}
Feel free to submit Pull Requests or report Issues. For more details, check out the contribution guidelines.
Huge thanks to the contributors thus far!
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.