ratelimit

package
v1.6.4 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RateLimit

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

func NewRateLimit

func NewRateLimit(threshold int, window time.Duration) *RateLimit

NewRateLimit initializes a new RateLimit instance with the given threshold and window duration.

func (*RateLimit) AllowRequest

func (r *RateLimit) AllowRequest() bool

AllowRequest increments the counter and checks if the rate limit is exceeded. If the threshold is zero, it allows all requests.

Jump to

Keyboard shortcuts

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