ratelimit

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2023 License: MIT Imports: 3 Imported by: 1

README

ratelimit

A Golang rate limit implementation

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 allows a burst of request during the defined duration

func New

func New(ctx context.Context, max int64, duration time.Duration) *Limiter

New creates a new limiter instance with the tokens amount and the interval

func NewUnlimited

func NewUnlimited(ctx context.Context) *Limiter

NewUnlimited create a bucket with approximated unlimited tokens

func (*Limiter) Take

func (rateLimiter *Limiter) Take()

Take one token from the bucket

Jump to

Keyboard shortcuts

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