Skip to content
/ ratelimit Public

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

License

Notifications You must be signed in to change notification settings

iand/ratelimit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages