Class BurstyRateLimiterStats


  • class BurstyRateLimiterStats
    extends RateLimiterStats
    A rate limiter implementation that allows bursts of executions, up to the max permits per period. This implementation tracks the current period and available permits, which can go into a deficit. A deficit of available permits will cause wait times for callers that can be several periods long, depending on the size of the deficit and the number of requested permits.
    • Field Detail

      • periodPermits

        final long periodPermits
      • periodNanos

        private final long periodNanos
      • availablePermits

        private long availablePermits
      • currentPeriod

        private long currentPeriod
    • Method Detail

      • acquirePermits

        public long acquirePermits​(long requestedPermits,
                                   java.time.Duration maxWaitTime)
        Description copied from class: RateLimiterStats
        Eagerly acquires permits and returns the time in nanos that must be waited in order to use the permits, else returns -1 if the wait time would exceed the maxWaitTime.
        Specified by:
        acquirePermits in class RateLimiterStats
        Parameters:
        requestedPermits - the number of requested permits
        maxWaitTime - the max time to wait for the requested permits, else null to wait indefinitely
      • getAvailablePermits

        long getAvailablePermits()
      • getCurrentPeriod

        long getCurrentPeriod()