rate_limit

package
v0.0.0-...-1726717 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dependencies

type Dependencies struct {
	Log        *zerolog.Logger
	RedisStore RedisClient
}

Dependencies for rate limit provider

type Provider

type Provider interface {
	// Allow checks if a request from the given IP should be allowed
	Allow(ctx context.Context, ip string) (bool, error)
	// Close cleans up resources used by the provider
	Close() error
}

Provider defines the rate limiting interface

func New

func New(cfg *config.Config, deps *Dependencies) (Provider, error)

New creates a new rate limit provider based on available infrastructure. Uses Redis when RedisStore is provided, falls back to in-memory.

type RedisClient

type RedisClient = redis.Cmdable

RedisClient is any Redis client that supports Eval (e.g., *redis.Client, *redis.ClusterClient)

Jump to

Keyboard shortcuts

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