ratelimit

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2019 License: MIT Imports: 3 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 interface {
	// Take should block to make sure that the RPS is met before returning true.
	// If the passed in channel is closed, Take should unblock and return false.
	Take(cancel <-chan struct{}) bool
}

Limiter is used to rate limit some process, possibly across goroutines. The process is expected to call Take() before every iteration, which may block to throttle the process.

func New

func New(rps int) Limiter

New returns a Limiter that will limit to the given RPS.

func NewInfinite

func NewInfinite() Limiter

NewInfinite returns a RateLimiter that is not limited.

Jump to

Keyboard shortcuts

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