ratelimiter

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2025 License: Apache-2.0 Imports: 5 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RateLimiter

type RateLimiter interface {
	// Get retrieves the current rate limit usage for the given key.
	// Returns the current value of the rate limit counter and an error if retrieval fails.
	Get(ctx context.Context, key string) (int64, error)

	// GetLimit retrieves the configured maximum rate limit for the given key.
	// Returns the maximum allowed value for the rate limit and an error if retrieval fails.
	GetLimit(ctx context.Context, key string) (int64, error)

	// Incr increments the rate limit counter for the given key by the specified value.
	// Returns the updated rate limit counter after the increment and an error if the operation fails.
	Incr(ctx context.Context, key string, val int64) (int64, error)
}

RateLimiter defines an interface for rate limiting operations. It allows querying, retrieving limits, and incrementing usage for a given key.

func NewRedisAccountRateLimiter

func NewRedisAccountRateLimiter(name string, client *redis.Client, windowSize time.Duration) RateLimiter

NewRedisAccountRateLimiter is a simple fixed window rate limiter

Jump to

Keyboard shortcuts

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