ratelimiter

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: MIT Imports: 8 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) GateReq added in v1.1.3

func (limiter *Limiter) GateReq(client *http.Client, origReq *http.Request, body []byte) (*http.Response, error)

GateReq will make the http request but will force it to comply with concurrent limits, rate limits, and it will also retry requests that receive 429. When a 429 occurs, it will cancel all inflight requests and pauses, so that the requests dont continue to batter the server and cause bot detection

Jump to

Keyboard shortcuts

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