Package dev.failsafe.internal
Class RateLimiterStats
java.lang.Object
dev.failsafe.internal.RateLimiterStats
- Direct Known Subclasses:
BurstyRateLimiterStats,SmoothRateLimiterStats
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) abstract longacquirePermits(long permits, Duration maxWaitTime) Eagerly acquires permits and returns the time in nanos that must be waited in order to use the permits, else returns-1if the wait time would exceed themaxWaitTime.(package private) booleanexceedsMaxWaitTime(long waitNanos, Duration maxWaitTime) Returns whether thewaitNanoswould exceed themaxWaitTime, elsefalseifmaxWaitTimeis null.(package private) DurationReturns the elapsed time since the rate limiter began.(package private) abstract voidreset()Resets the rate limiter's internal stats.
-
Field Details
-
stopwatch
-
-
Constructor Details
-
RateLimiterStats
RateLimiterStats(RateLimiterStats.Stopwatch stopwatch)
-
-
Method Details
-
acquirePermits
Eagerly acquires permits and returns the time in nanos that must be waited in order to use the permits, else returns-1if the wait time would exceed themaxWaitTime.- Parameters:
permits- the number of requested permitsmaxWaitTime- the max time to wait for the requested permits, elsenullto wait indefinitely
-
exceedsMaxWaitTime
Returns whether thewaitNanoswould exceed themaxWaitTime, elsefalseifmaxWaitTimeis null. -
getElapsed
Duration getElapsed()Returns the elapsed time since the rate limiter began. -
reset
abstract void reset()Resets the rate limiter's internal stats.
-