ratelimiter

package
v0.0.0-...-8699099 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 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 RateLimiter

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

RateLimiter manages rate limiting for incoming requests based on IP addresses. It enforces a minimum duration between allowed requests from the same IP.

func NewRateLimiter

func NewRateLimiter(limit time.Duration) *RateLimiter

NewRateLimiter initializes a new RateLimiter with a specified rate limit.

func (*RateLimiter) Allow

func (rl *RateLimiter) Allow(ip string) (bool, time.Duration)

Allow determines whether a request from a given IP address is allowed based on the rate limit.

Jump to

Keyboard shortcuts

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