/hqgolimit

A Go(Golang) package for handling rate limiting.

Primary LanguageGoMIT LicenseMIT

hqgolimit

license maintenance open issues closed issues contribution

A Go(Golang) package for handling rate limiting.

Installation

go get -v -u github.com/hueristiq/hqgolimit

Usage

package main

import (
	"fmt"
	"github.com/hueristiq/hqgolimit"
)

func main() {
	options := &hqgolimit.Options{
		RequestsPerMinute: 40,
		MinimumDelayInSeconds: 2,
	}

	limiter := hqgolimit.New(options)

	// Make 10 requests and ensure that they are rate limited.
	for i := 1; i <= 10; i++ {
		limiter.Wait()
		fmt.Printf("Request %d made at %v\n", i, time.Now())
	}
}

Contributing

Issues and Pull Requests are welcome! Check out the contribution guidelines.

Licensing

This package is distributed under the MIT license.