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 provides efficient rate limiting. The zero value is immediately usable.
A Limiter is not safe to use from multiple goroutines simultaneously.
type Ticker ¶ added in v1.3.0
type Ticker struct {
C <-chan struct{}
// contains filtered or unexported fields
}
func NewSubTicker ¶ added in v1.1.0
NewSubTicker returns a channel that reads from another struct{}{} channel and then sends a `struct{}{}` at most `*maxrate` times per second, but that cannot exceed the parent tick rate.
If counter is not nil, it is incremented every time a send is successful.
Use this to make "background" tickers that are less prioritized.
The Ticker is closed when the parent channel closes.
func NewTicker ¶
NewTicker returns a Ticker that sends a `struct{}{}` at most `*maxrate` times per second on it's C channel.
If counter is not nil, it is incremented every time a send is successful.
A nil `maxrate` or a `*maxrate` of zero or less sends as quickly as possible.
func (*Ticker) AddTick ¶ added in v1.3.0
AddTick adds a single tick to the Ticker, retrying with the given interval until it succeeds or the Ticker is closed.