ratelimiter

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBackoff = errors.New("Backoff")

Functions

This section is empty.

Types

type Config

type Config struct {
	BurstLimit   int64         // Number of requests to allow to burst.
	FillPeriod   time.Duration // Add one call per period.
	MaxWaitCount int64         // Max number of waiting requests. 0 disables.
}

type Limiter

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

func New

func New(conf Config) *Limiter

func (*Limiter) Limit

func (lim *Limiter) Limit() error

Apply the limiter to the calling thread. The function may sleep for up to maxWaitTime before returning. If the timeout would need to be more than maxWaitTime to enforce the rate limit, ErrBackoff is returned.

Jump to

Keyboard shortcuts

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