A Go(Golang) package for handling rate limiting.
To install the package, run the following command in your terminal:
go get -v -u github.com/hueristiq/hq-go-limiter
This command will download and install the hq-go-limiter
package into your Go workspace, making it available for use in your projects.
Here's a simple example demonstrating how to use hq-go-limiter
:
package main
import (
"fmt"
limiter "github.com/hueristiq/hq-go-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())
}
}
We welcome contributions! Feel free to submit Pull Requests or report Issues. For more details, check out the contribution guidelines.
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.
A huge thanks to all the contributors who have helped make hq-go-limiter
what it is today!
If you're interested in more packages like this, check out: