middleware

package
v1.25.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 30, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL