Interface RateLimitStrategy

All Known Implementing Classes:
ApiKeyRateLimiter, Bucket4jRateLimiter, GuavaRateLimiter, JwtRateLimiter, LeakyBucketRateLimiter, OAuth2RateLimiter, RbacRateLimiter, RedisRateLimiter, Resilience4jRateLimiter, TokenBucketRateLimiter

public interface RateLimitStrategy
Interface for rate-limiting strategies.

All rate-limiting implementations must implement this interface.

  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    allowRequest(String key, int limit, int duration)
    Checks if a request is allowed based on the rate-limiting rules.
  • Method Details

    • allowRequest

      boolean allowRequest(String key, int limit, int duration)
      Checks if a request is allowed based on the rate-limiting rules.
      Parameters:
      key - the unique key for the rate limit (e.g., user ID, IP)
      limit - the maximum number of requests allowed
      duration - the time window (in seconds) for the rate limit
      Returns:
      true if the request is allowed, false otherwise