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 DefaultTicker has been stopped, returns nil. If you provide limits, the first will set both read and write limits, the second will set the write limit. Limits are applied in 100ms slices with fractional carry-over between slices, so very low rates are accurate over time but can be bursty at slice boundaries.
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.
Count and Rate metrics are not updated after Stop.
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. Ticker values must be created with NewTicker; the zero value is not supported.
func NewTicker ¶ added in v1.0.0
func NewTicker() (ot *Ticker)
NewTicker creates and starts a Ticker.
func (*Ticker) NewLimiter ¶ added in v0.11.0
NewLimiter returns a new Limiter using this Ticker. If this Ticker is stopped, returns nil.
If you provide limits, the first will set both read and write limits, the second will set the write limit. Limits are applied in 100ms slices with fractional carry-over between slices, so very low rates are accurate over time but can be bursty at slice boundaries.
To stop the limiter and free it's resources, call Stop.