Documentation ¶
Overview ¶
Package ratelimit provides filters to control the rate limitter settings on the route level.
For detailed documentation of the ratelimit, see https://godoc.org/github.com/zalando/skipper/ratelimit.
Index ¶
- func NewClientRatelimit(provider RatelimitProvider) filters.Spec
- func NewClusterClientRateLimit(provider RatelimitProvider) filters.Spec
- func NewClusterRateLimit(provider RatelimitProvider) filters.Spec
- func NewDisableRatelimit(provider RatelimitProvider) filters.Spec
- func NewLocalRatelimit(provider RatelimitProvider) filters.Spec
- func NewRatelimit(provider RatelimitProvider) filters.Spec
- type RatelimitProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewClientRatelimit ¶ added in v0.10.168
func NewClientRatelimit(provider RatelimitProvider) filters.Spec
NewClientRatelimit creates a instance based client rate limit. If you have 5 instances with 20 req/s, then it would allow 100 req/s to the backend from the same client. A third argument can be used to set which HTTP header of the request should be used to find the same user. Third argument defaults to XForwardedForLookuper, meaning X-Forwarded-For Header.
Example:
backendHealthcheck: Path("/healthcheck") -> clientRatelimit(20, "1m") -> "https://foo.backend.net";
Example rate limit per Authorization Header:
login: Path("/login") -> clientRatelimit(3, "1m", "Authorization") -> "https://login.backend.net";
func NewClusterClientRateLimit ¶ added in v0.10.153
func NewClusterClientRateLimit(provider RatelimitProvider) filters.Spec
NewClusterClientRatelimit creates a rate limiting that is aware of the other instances. The value given here should be the combined rate of all instances. The ratelimit group parameter can be used to select the same ratelimit group across one or more routes.
Example:
backendHealthcheck: Path("/login") -> clusterClientRatelimit("groupB", 20, "1h") -> "https://foo.backend.net";
The above example would limit access to "/login" if, the client did more than 20 requests within the last hour to this route across all running skippers in the cluster. A single client can be detected by different data from the http request and defaults to client IP or X-Forwarded-For header, if exists. The optional third parameter chooses the HTTP header to choose a client is counted as the same.
Example:
backendHealthcheck: Path("/login") -> clusterClientRatelimit("groupC", 20, "1h", "Authorization") -> "https://foo.backend.net";
func NewClusterRateLimit ¶ added in v0.10.113
func NewClusterRateLimit(provider RatelimitProvider) filters.Spec
NewClusterRatelimit creates a rate limiting that is aware of the other instances. The value given here should be the combined rate of all instances. The ratelimit group parameter can be used to select the same ratelimit group across one or more routes.
Example:
backendHealthcheck: Path("/healthcheck") -> clusterRatelimit("groupA", 200, "1m") -> "https://foo.backend.net";
func NewDisableRatelimit ¶
func NewDisableRatelimit(provider RatelimitProvider) filters.Spec
NewDisableRatelimit disables rate limiting
Example:
backendHealthcheck: Path("/healthcheck") -> disableRatelimit() -> "https://foo.backend.net";
func NewLocalRatelimit ¶
func NewLocalRatelimit(provider RatelimitProvider) filters.Spec
NewLocalRatelimit is *DEPRECATED*, use NewClientRatelimit, instead
func NewRatelimit ¶
func NewRatelimit(provider RatelimitProvider) filters.Spec
NewRatelimit creates a service rate limiting, that is only aware of itself. If you have 5 instances with 20 req/s, then it would at max allow 100 req/s to the backend.
Example:
backendHealthcheck: Path("/healthcheck") -> ratelimit(20, "1s") -> "https://foo.backend.net";
Types ¶
type RatelimitProvider ¶ added in v0.11.190
type RatelimitProvider interface {
// contains filtered or unexported methods
}
RatelimitProvider returns a limit instance for provided Settings
func NewRatelimitProvider ¶ added in v0.11.190
func NewRatelimitProvider(registry *ratelimit.Registry) RatelimitProvider