⏳ Super simple rate-limited task pool
// 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()
This library is distributed under the MIT License, see LICENSE.txt for more information.