Interface RateLimiter
- All Superinterfaces:
AutoCloseable,Serializable
- All Known Implementing Classes:
EnvoyRateLimiter
A RateLimiter allows to fetch permits from a rate limiter service and blocks execution when the
rate limit is exceeded.
Implementations must be Serializable as they are passed to workers.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanallow(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.Methods inherited from interface java.lang.AutoCloseable
close
-
Method Details
-
allow
Blocks 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:
IOException- if there is an error communicating with the rate limiter service.InterruptedException- if the thread is interrupted while waiting.
-