Created
December 5, 2014 16:21
-
-
Save martinos/4024fa1e54ebeb737de0 to your computer and use it in GitHub Desktop.
Rate limiter in golang
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "time" | |
rate_per_sec := 10 | |
throttle := time.Tick(1e9 / rate_per_sec) | |
for req := range requests { | |
<-throttle // rate limit our Service.Method RPCs | |
go client.Call("Service.Method", req, ...) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment