Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Limiter ¶
type Limiter struct {
// contains filtered or unexported fields
}
Limiter is a helper tool which allows controlling the number and concurrency of requests made against a generic target.
func NewLimiter ¶
func NewLimiter( config *LimiterConfig, ) *Limiter
NewLimiter creates a new rate limiter instance basing on given config.
func (*Limiter) AcquirePermit ¶
AcquirePermit acquires the permit.
func (*Limiter) ReleasePermit ¶
func (l *Limiter) ReleasePermit()
ReleasePermit releases the permit.
type LimiterConfig ¶
type LimiterConfig struct {
// RequestsPerSecondLimit sets the maximum average number of requests
// per second. It's important to note that in short periods of time
// the actual average may exceed this limit slightly.
RequestsPerSecondLimit int
// ConcurrencyLimit sets the maximum number of concurrent requests which
// can be executed against the target at the same time.
ConcurrencyLimit int
// AcquirePermitTimeout determines how long a request can wait trying
// to acquire a permit from the rate limiter.
AcquirePermitTimeout time.Duration
}
LimiterConfig represents the configuration of the rate limiter.
Click to show internal directories.
Click to hide internal directories.