Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/brynbellomy/go-ratelimiter
A simple rate limiter.
https://github.com/brynbellomy/go-ratelimiter
Last synced: about 1 month ago
JSON representation
A simple rate limiter.
- Host: GitHub
- URL: https://github.com/brynbellomy/go-ratelimiter
- Owner: brynbellomy
- Created: 2016-02-09T21:21:17.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-02-09T21:21:24.000Z (almost 9 years ago)
- Last Synced: 2024-04-17T00:55:58.556Z (7 months ago)
- Language: Go
- Homepage: https://godoc.org/github.com/brynbellomy/go-ratelimiter
- Size: 0 Bytes
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ratelimiter
A simple rate limiter. Warning: it's not perfectly accurate — you will still have to handle overages. With that said, it works pretty well.
```go
import (
"github.com/brynbellomy/go-ratelimiter"
)func main() {
rl := ratelimiter.New(1000, 1 * time.Second)for {
doWork(rl)
}
}func doWork(rl *ratelimiter.RateLimiter) {
rl.GetCapacity(1) // blocks
defer rl.ReleaseCapacity(1)// ... do some work ...
}
```