Package com.rale4j.sb.core
Class Bucket4jRateLimiter
java.lang.Object
com.rale4j.sb.core.Bucket4jRateLimiter
- All Implemented Interfaces:
RateLimitStrategy
Rate limiter implementation using Bucket4j.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
allowRequest
(String key, int limit, int duration) Checks if a request is allowed based on the rate-limiting rules.
-
Constructor Details
-
Method Details
-
allowRequest
Description copied from interface:RateLimitStrategy
Checks if a request is allowed based on the rate-limiting rules.- Specified by:
allowRequest
in interfaceRateLimitStrategy
- 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
-