Skip to content
/ rate Public

rate limit the execution of a function in Go

License

Notifications You must be signed in to change notification settings

117/rate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rate

func main() {
  limiter := rate.NewLimiter(3, time.Second)

  for {
    limiter.SleepIfRateExceeded(func() {
      fmt.Println("only printed 3 times per second")
    })
  }
}