Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Limiter ¶
type Limiter interface { // Consume is a blocking call once you have Consume(context.Context) error }
Limiter defines the basic definition of a rater limiter
type NullLimiter ¶
type NullLimiter struct{}
NullLimiter satisfies the Limiter interface and should only be used for testing purposes
type Throttler ¶
type Throttler struct {
// contains filtered or unexported fields
}
Throttler allows for up to fix number of actions to happen within a fixed interval with accounting for jitters
func NewThrottler ¶
NewThrottler will configure a new rater limiting bucket with max of limit / (interval + [0,jitter)) ==> rate Once the limit has been breached, it will pause computation for that thread until the interval + jitter amount has been reached
func (*Throttler) Consume ¶
Consume will take one place in the internal semiphore and will block once we have reached out limit and delay the processing of blocked this does mean that blocked will be delayed instead of dropped.