Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/joshdk/ratelimit
⏳ Super simple rate-limited task pool
https://github.com/joshdk/ratelimit
golang pool rate-limiter
Last synced: about 5 hours ago
JSON representation
⏳ Super simple rate-limited task pool
- Host: GitHub
- URL: https://github.com/joshdk/ratelimit
- Owner: joshdk
- License: mit
- Created: 2017-10-10T13:01:56.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2017-10-13T18:20:24.000Z (about 7 years ago)
- Last Synced: 2024-06-20T02:08:05.208Z (5 months ago)
- Topics: golang, pool, rate-limiter
- Language: Shell
- Size: 65.4 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
[![License](https://img.shields.io/github/license/joshdk/ratelimit.svg)](https://opensource.org/licenses/MIT)
[![GoDoc](https://godoc.org/github.com/joshdk/ratelimit?status.svg)](https://godoc.org/github.com/joshdk/ratelimit)
[![Go Report Card](https://goreportcard.com/badge/github.com/joshdk/ratelimit)](https://goreportcard.com/report/github.com/joshdk/ratelimit)
[![CircleCI](https://circleci.com/gh/joshdk/ratelimit.svg?&style=shield)](https://circleci.com/gh/joshdk/ratelimit/tree/master)
[![CodeCov](https://codecov.io/gh/joshdk/ratelimit/branch/master/graph/badge.svg)](https://codecov.io/gh/joshdk/ratelimit)# Ratelimit
⏳ Super simple rate-limited task pool
## Usage
```go
// Create a pool that can run 10 tasks per second
pool := ratelimit.NewPool(10, time.Second)// Add 100 tasks to the pool
for i := 0; i < 100; i++ {
i := i
pool.Add(func() {
fmt.Printf("this is job #%d\n", i)
})
}// Sleep for 10 seconds as tasks execute
time.Sleep(10 * time.Second)// Stop task execution and wait
pool.Stop()
pool.Wait()
```## License
This library is distributed under the [MIT License](https://opensource.org/licenses/MIT), see LICENSE.txt for more information.