ratelimiter

package
v0.0.0-...-4d3ba72 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2024 License: Apache-2.0 Imports: 3 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
}

func New

func New(rps int) *RateLimiter

New returns a new Limiter that allows events up to r requests per second.

func (*RateLimiter) Allow

func (l *RateLimiter) Allow() bool

Allow returns true if the request should be allowed.

func (*RateLimiter) AllowN

func (l *RateLimiter) AllowN(n int) bool

AllowN returns true if N requests should be allowed.

func (*RateLimiter) Limit

func (l *RateLimiter) Limit() int

Limit returns the maximum overall event rate. Zero is returned when there is no limit specified.

func (*RateLimiter) WaitN

func (l *RateLimiter) WaitN(ctx context.Context, n int) (err error)

WaitN blocks until it permits n events to happen

Jump to

Keyboard shortcuts

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