rate_limiter

package
v0.0.0-...-a06e19b Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NOTE: Empty RateLimiter is unlimited one
	UNLIMITED = 0
	DISABLED  = -1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type RateLimit

type RateLimit struct {
	Limit  int64
	Period time.Duration
}

type RateLimiter

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

NOTE: GCRA Rate Limiter https://en.wikipedia.org/wiki/Generic_cell_rate_algorithm

func Disabled

func Disabled() RateLimiter

func New

func New(rl RateLimit) RateLimiter

func Unlimited

func Unlimited() RateLimiter

func (*RateLimiter) Acquire

func (rl *RateLimiter) Acquire() (bool, int64)

func (*RateLimiter) Wait

func (rl *RateLimiter) Wait(ctx context.Context) error

Jump to

Keyboard shortcuts

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