Skip to content

joshdk/ratelimit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

License GoDoc Go Report Card CircleCI CodeCov

Ratelimit

⏳ Super simple rate-limited task pool

Usage

// 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, see LICENSE.txt for more information.

About

⏳ Super simple rate-limited task pool

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published