package main
import (
"fmt"
"github.com/vcraescu/go-ratelimit"
"log"
"time"
)
func worker(i int) {
fmt.Printf("worker: %d\n", i)
}
func main() {
limiter := ratelimit.NewLimiter(10, ratelimit.WithPer(time.Second))
for i := 0; i < 50; i++ {
i := i
limiter.Run(func() {
worker(i)
})
}
if err := limiter.Wait(); err != nil {
log.Fatalln(err)
}
}
-
Notifications
You must be signed in to change notification settings - Fork 0
Go blocking leaky-bucket function rate limit
License
vcraescu/go-ratelimit
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
Go blocking leaky-bucket function rate limit
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published