Class RecyclableRateLimiter
- java.lang.Object
-
- com.google.common.util.concurrent.RateLimiter
-
- com.google.common.util.concurrent.RecyclableRateLimiter
-
public class RecyclableRateLimiter extends com.google.common.util.concurrent.RateLimiter
An alternative RateLimiter implementation that allows to "return" unused permits back to the pool to handle retries gracefully and allow precise control over outgoing rate, plus allows accumulating "credits" for unused permits over a time window other than 1 second. Created by: [email protected], with portions from Guava library source code
-
-
Field Summary
Fields Modifier and Type Field Description static int
UNLIMITED
This rate limit is considered "unlimited"
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static RecyclableRateLimiter
create(double permitsPerSecond, double maxBurstSeconds)
double
getAvailablePermits()
Get the number of accumulated permitsvoid
recyclePermits(int permits)
Return the specified number of permits back to the pool
-
-
-
Method Detail
-
create
public static RecyclableRateLimiter create(double permitsPerSecond, double maxBurstSeconds)
-
getAvailablePermits
public double getAvailablePermits()
Get the number of accumulated permits- Returns:
- number of accumulated permits
-
recyclePermits
public void recyclePermits(int permits)
Return the specified number of permits back to the pool- Parameters:
permits
- number of permits to return
-
-