Documentation
¶
Overview ¶
Package ratelimit provides a net.Conn wrapper that throttles read and write throughput using a token bucket. It is meant to be applied at the dial level so the underlying protocol library (go-imap) is unaware of throttling.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewLimiter ¶
NewLimiter constructs a *rate.Limiter for the given bytes-per-second budget. Returns nil when bps <= 0, signaling "unlimited" to callers.
Types ¶
type Conn ¶
Conn wraps a net.Conn and applies token-bucket rate limiting to Read and Write. Either limiter may be nil — that direction is then unlimited.
Conn is safe for concurrent use by multiple goroutines because *rate.Limiter is itself concurrency-safe and net.Conn implementations are required to be safe for concurrent reads and writes.