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
Click to show internal directories.
Click to hide internal directories.