Documentation
¶
Overview ¶
Package limits caps work per key (a source, later a host): how many tasks run at once, and how fast requests go. The caps hold across all users' work. They live in memory, which fits a single server instance.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Default = Limit{Concurrency: 2, Every: 500 * time.Millisecond, Burst: 4}
Default is the cap of keys nobody set: polite to sites that said nothing about their limits.
Functions ¶
This section is empty.
Types ¶
type Key ¶
type Key struct {
// contains filtered or unexported fields
}
Key is the live cap of one key.
func (*Key) TryAcquire ¶
TryAcquire takes a concurrency slot if one is free.
type Limit ¶
type Limit struct {
// Concurrency is how many tasks may hold the key at once (at least 1).
Concurrency int
// Every is the time between two requests; 0 means no rate limit.
Every time.Duration
// Burst is how many requests may go at once after a quiet spell.
Burst int
}
Limit is the cap of one key.
Click to show internal directories.
Click to hide internal directories.