ratelimiter

package
v1.18.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2023 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Limiter

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

Limiter is a thread-safe counter that can be used for rate-limiting requests

func New

func New(maxRequests int) *Limiter

New creates a Limiter with the specified maximum concurrent requests

func (*Limiter) Dec

func (l *Limiter) Dec()

func (*Limiter) TryInc

func (l *Limiter) TryInc() bool

If there is still room, TryInc, increases the counter and returns true. If there are too many concurrent requests it does not increase the counter and returns false

Jump to

Keyboard shortcuts

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