Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RateLimiters ¶
type RateLimiters struct { RPS float64 Burst int Logger log.Logger // contains filtered or unexported fields }
Use `*RateLimiter.RoundTripper(host)` to obtain a rate limited HTTP transport for an operation. The RoundTripper will react to a `HTTP 429 Too many requests` response by reducing the limit for that host. It will only do so once, so that concurrent requests don't *also* reduce the limit.
Call `*RateLimiter.Recover(host)` when an operation has succeeded without incident, which will increase the rate limit modestly back towards the given ideal.
func (*RateLimiters) Recover ¶
func (limiters *RateLimiters) Recover(host string)
Recover should be called when a use of a RoundTripper has succeeded, to bump the limit back up again.
func (*RateLimiters) RoundTripper ¶
func (limiters *RateLimiters) RoundTripper(rt http.RoundTripper, host string) http.RoundTripper
Limit returns a RoundTripper for a particular host. We expect to do a number of requests to a particular host at a time.