Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultNetDialer = &net.Dialer{}
Functions ¶
This section is empty.
Types ¶
type ContextDialer ¶ added in v0.12.0
type Dialer ¶
type Dialer struct {
ContextDialer // ContextDialer we wrap
*Limiter // Limiter to use
}
type Limiter ¶
func NewLimiter ¶
NewLimiter returns a new limiter from DefaultTicker. If you provide limits, the first will set both read and write limits, the second will set the write limit.
To stop the Limiter and free it's resources, call Stop.
func (*Limiter) Stop ¶ added in v0.11.0
func (l *Limiter) Stop()
Stop stops the Limiter and frees any resources. Reads and writes on a stopped and rate-limited Limiter returns io.EOF. On an unlimited Limiter they function as normal.
func (*Limiter) Wrap ¶ added in v0.7.0
func (l *Limiter) Wrap(cd ContextDialer) ContextDialer
Wrap returns a ContextDialer wrapping cd that is bandwidth limited by this Limiter.
If cd is nil we use DefaultNetDialer. If cd is already limited by this Limiter, cd is returned unchanged.
type Operation ¶
type Ticker ¶ added in v0.10.0
type Ticker struct {
// contains filtered or unexported fields
}
A Ticker synchronizes rate calculation among multiple Limiters.
var DefaultTicker *Ticker
func (*Ticker) NewLimiter ¶ added in v0.11.0
NewLimiter returns a new Limiter using this Ticker. If you provide limits, the first will set both read and write limits, the second will set the write limit.
To stop the limiter and free it's resources, call Stop.