Package com.rale4j.sb.core
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 TypeMethodDescriptionbooleanallowRequest(String key, int limit, int duration) Checks if a request is allowed based on the rate-limiting rules.
-
Method Details
-
allowRequest
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 allowedduration- the time window (in seconds) for the rate limit- Returns:
- true if the request is allowed, false otherwise
-