ratelimiter

package
v0.0.0-...-ec279c9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 15, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RateLimit

func RateLimit(rateLimiters []*SlidingWindow, n int, retryDuration time.Duration)

RateLimit checks the rate limiters given and blocks/retries until all rate limiters allow n records.

Types

type SlidingWindow

type SlidingWindow struct {
	*slidingwindow.Limiter
	// contains filtered or unexported fields
}

SlidingWindow is a rate limiter using a sliding window for limiting the records.

func NewSlidingWindowRateLimiter

func NewSlidingWindowRateLimiter(windowSize time.Duration, limit int64, blockCounter prometheus.Counter) *SlidingWindow

NewSlidingWindowRateLimiter creates a rate limiter which uses a sliding window.

func (*SlidingWindow) Allow

func (sw *SlidingWindow) Allow(n int64) bool

Allow checks if n records can be allowed by the sliding window rate limiter. It increases the number of blocking readers when denies the records.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL