ratelimiter

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2020 License: MIT Imports: 3 Imported by: 1

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 keeps track of an api rate limit and wont let you pass the limit

func New

func New(domain string, reqPerSec int) *Limiter

New creates a new call rate limiter for a single domain

func (*Limiter) ResetAfter added in v1.1.0

func (limiter *Limiter) ResetAfter(after time.Duration)

ResetAfter will reset the bucket to 0, wait for the amount of time until it resumes This will allow the rate limiter to stop all activity and restart slowly

func (*Limiter) Wait

func (limiter *Limiter) Wait()

Wait will block until enough time has passed and the limit will not be passed

Jump to

Keyboard shortcuts

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