ratelimiter

package
v0.31.0-victorialogs Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RateLimiter

type RateLimiter struct {
	// contains filtered or unexported fields
}

RateLimiter limits per-second rate of arbitrary resources.

Call Register() for registering the given amounts of resources.

func New

func New(perSecondLimit int64, limitReached *metrics.Counter, stopCh <-chan struct{}) *RateLimiter

New creates new rate limiter with the given perSecondLimit.

stopCh is used for unblocking Register() calls when the rate limiter is no longer needed.

func (*RateLimiter) Register

func (rl *RateLimiter) Register(count int)

Register registers count resources.

Register blocks if the given per-second rate limit is exceeded. It may be forcibly unblocked by closing stopCh passed to New().

Jump to

Keyboard shortcuts

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