hyperate provides a wrapper around a http.RoundTripper
to help rate limit
outgoing HTTP requests.
go get github.com/dstotijn/hyperate
// Create an http.RoundTripper that rate limits outgoing HTTP requests to 10
// per second, allowing bursts of 5 requests.
rt := hyperate.New(http.DefaultTransport, rate.NewLimiter(10, 5))
client := &http.Client{Transport: rt}
Use HTTP response headers (RateLimit-Remaining
and RateLimit-Reset
)
(draft-polli-ratelimit-headers-02)
to continously set rate limit.
rt := hyperate.New(http.DefaultTransport, rate.NewLimiter(rate.Inf, 1),
hyperate.WithRateLimitHeaderCheck(),
)
client := &http.Client{Transport: rt}
© 2023 David Stotijn