Documentation ¶
Index ¶
- type Limiter
- func (lim *Limiter) Allow() bool
- func (lim *Limiter) AllowFor(timeout time.Duration) bool
- func (lim *Limiter) AllowN(now time.Time, n int, timeout time.Duration) bool
- func (lim *Limiter) AllowWaitUntil() bool
- func (lim *Limiter) Burst() int
- func (lim *Limiter) Bursting() int
- func (lim *Limiter) Put() bool
- func (lim *Limiter) PutN(n int) bool
- func (lim *Limiter) WaitFor(timeout time.Duration) (err error)
- func (lim *Limiter) WaitN(timeout time.Duration, n int) (err error)
- type Reservation
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
}
func NewLimiter ¶
NewLimiter returns a new Limiter that allows events up to rate r and permits bursts of at most b tokens.
func (*Limiter) AllowN ¶
AllowN reports whether n events may happen at time now. Use this method if you intend to drop / skip events that exceed the rate limit. Otherwise use Reserve or Wait.
func (*Limiter) AllowWaitUntil ¶ added in v0.0.78
AllowWaitUntil is shorthand for AllowFor(-1).
func (*Limiter) Burst ¶
Burst returns the maximum burst size. Burst is the maximum number of tokens that can be consumed in a single call to Allow, Reserve, or Wait, so higher Burst values allow more events to happen at once. A zero Burst allows no events, unless limit == Inf.
func (*Limiter) WaitFor ¶
A Reservation holds information about events that are permitted by a Limiter to happen after a delay. A Reservation may be canceled, which may enable the Limiter to permit additional events. Wait is shorthand for WaitN(ctx, 1).
type Reservation ¶
type Reservation struct {
// contains filtered or unexported fields
}