Skip to content

Repository files navigation

RateLimit

GoDocLicense

Simple, thread-safe Go rate-limiter. Inspired by Antti Huima's algorithm on http://stackoverflow.com/a/668327

Example

package main
import (
"github.com/bsm/ratelimit/v3""log"
)
funcmain() {
// Create a new rate-limiter, allowing up-to 10 calls// per secondrl:=ratelimit.New(10, time.Second)
fori:=0; i<20; i++ {
ifrl.Limit() {
fmt.Println("Doh! Over limit!")
} else {
fmt.Println("OK")
}
}
}

Documentation

Full documentation is available on pkg.go.dev.

About

Simple, thread-safe Go rate-limiter

Resources

Stars

81 stars

Watchers

7 watching

Forks

Releases

Packages

Used by

Contributors

Languages