@Beta public final class RateLimiter extends Object implements AutoCloseable, PermitSupplier
Constructor and Description |
---|
RateLimiter(double maxReqPerSecond,
int maxBurstSize) |
RateLimiter(double maxReqPerSecond,
int maxBurstSize,
long minReplenishIntervalMillis) |
RateLimiter(double maxReqPerSecond,
int maxBurstSize,
long minReplenishIntervalMillis,
ScheduledExecutorService scheduler,
LongSupplier nanoTimeSupplier) |
RateLimiter(double maxReqPerSecond,
int maxBurstSize,
long minReplenishIntervalMillis,
ScheduledExecutorService scheduler,
LongSupplier nanoTimeSupplier,
int concurrencyLevel) |
RateLimiter(double maxReqPerSecond,
int maxBurstSize,
ScheduledExecutorService scheduler) |
RateLimiter(double maxReqPerSecond,
int maxBurstSize,
ScheduledExecutorService scheduler,
LongSupplier nanoTimeSupplier) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
long |
getLastReplenishmentNanos() |
double |
getNrPermits() |
long |
getPermitReplenishIntervalMillis() |
double |
getPermitsPerReplenishInterval() |
String |
toString() |
boolean |
tryAcquire()
Try to acquire a permit if available.
|
boolean |
tryAcquire(int nrPermits) |
boolean |
tryAcquire(int nrPermits,
long deadlineNanos) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
acquire, acquire, toSemaphore, tryAcquire, tryAcquire
public RateLimiter(double maxReqPerSecond, int maxBurstSize, long minReplenishIntervalMillis)
public RateLimiter(double maxReqPerSecond, int maxBurstSize)
public RateLimiter(double maxReqPerSecond, int maxBurstSize, ScheduledExecutorService scheduler)
public RateLimiter(double maxReqPerSecond, int maxBurstSize, ScheduledExecutorService scheduler, LongSupplier nanoTimeSupplier)
public RateLimiter(double maxReqPerSecond, int maxBurstSize, long minReplenishIntervalMillis, ScheduledExecutorService scheduler, LongSupplier nanoTimeSupplier)
public RateLimiter(double maxReqPerSecond, int maxBurstSize, long minReplenishIntervalMillis, ScheduledExecutorService scheduler, LongSupplier nanoTimeSupplier, int concurrencyLevel)
public boolean tryAcquire()
public boolean tryAcquire(int nrPermits)
public double getNrPermits()
public boolean tryAcquire(int nrPermits, long deadlineNanos) throws InterruptedException
tryAcquire
in interface PermitSupplier
InterruptedException
public void close()
close
in interface AutoCloseable
public double getPermitsPerReplenishInterval()
public long getPermitReplenishIntervalMillis()
public long getLastReplenishmentNanos()
Copyright © 2018 SPF4J. All rights reserved.