ratelimit

package
v0.0.0-...-17c6d09 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Global struct {
		Enabled bool
		Rate    float64
		Burst   int
	}
	PerIP struct {
		Enabled bool
		Rate    float64
		Burst   int
	}
	Redis    *redis.Client // Optional: only required for prefork mode
	UseRedis bool          // Whether to use Redis (true if prefork is enabled)
}

Config holds configuration for rate limiting

type RateLimiter

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

RateLimiter manages both global and per-IP rate limiting

func New

func New(config Config) *RateLimiter

New creates a new RateLimiter instance

func (*RateLimiter) Check

func (r *RateLimiter) Check(ip string) error

Check checks both global and IP-based rate limits

Jump to

Keyboard shortcuts

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