Skip to content

iand/ratelimit

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 

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