Go package for rate limiting of functions using a leacky bucket algorithm
Go
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
.travis.yml
README.md
UNLICENSE
ratelimit.go
ratelimit_test.go

README.md

ratelimit

Go package for rate limiting of functions using a leaky bucket algorithm

Build Status

Installation

Simply run

go get -u github.com/iand/ratelimit

Documentation is at http://godoc.org/github.com/iand/ratelimit

Usage

Example use:

import "github.com/iand/ratelimit"

func main() {
	limiter := ratelimit.PerSecond(5, 100)

	// Following should be executed at a rate of 5 per second
	for i := 0; i < 100; i++ {
		limiter.Do(func() { println("hello") })
	}

	// Blocks until the rate limiter has finished
	limiter.Drain()
}

LICENSE

This is free and unencumbered software released into the public domain. For more information, see http://unlicense.org/ or the accompanying UNLICENSE file.