Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HTTPDoer ¶
HTTPDoer is an interface for making HTTP requests. Both *http.Client and *RateLimitedHTTPClient satisfy this interface.
type Limiter ¶
type Limiter struct {
// contains filtered or unexported fields
}
Limiter implements a token bucket rate limiter. Thread-safe for concurrent use.
func NewLimiter ¶
NewLimiter creates a rate limiter with specified capacity and refill rate.
Example: NewLimiter(100, 10.0) creates a limiter with: - 100 token capacity - 10 tokens per second refill rate - Allows bursts up to 100 requests - Steady state: 10 requests/sec
func (*Limiter) TryAcquire ¶
TryAcquire attempts to acquire a token without blocking. Returns true if token acquired, false if none available.
type RateLimitedHTTPClient ¶
type RateLimitedHTTPClient struct {
// contains filtered or unexported fields
}
RateLimitedHTTPClient wraps an HTTPDoer with token bucket rate limiting.
func NewRateLimitedHTTPClient ¶
func NewRateLimitedHTTPClient(inner HTTPDoer, limiter *Limiter) *RateLimitedHTTPClient
NewRateLimitedHTTPClient wraps an existing HTTPDoer with rate limiting. If limiter is nil, requests pass through without rate limiting.