Interface RateLimiter
-
- All Superinterfaces:
java.lang.AutoCloseable,java.io.Serializable
- All Known Implementing Classes:
EnvoyRateLimiter
public interface RateLimiter extends java.io.Serializable, java.lang.AutoCloseableA RateLimiter allows to fetch permits from a rate limiter service and blocks execution when the rate limit is exceeded.Implementations must be
Serializableas they are passed to workers.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleanallow(int permits)Blocks until the specified number of permits are acquired and returns true if the request was allowed or false if the request was rejected.
-
-
-
Method Detail
-
allow
boolean allow(int permits) throws java.io.IOException, java.lang.InterruptedExceptionBlocks until the specified number of permits are acquired and returns true if the request was allowed or false if the request was rejected.- Parameters:
permits- Number of permits to acquire.- Returns:
- true if the request was allowed, false if it was rejected (and retries exceeded).
- Throws:
java.io.IOException- if there is an error communicating with the rate limiter service.java.lang.InterruptedException- if the thread is interrupted while waiting.
-
-