ratelimiter

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2025 License: Apache-2.0 Imports: 5 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 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