Class SmoothRateLimiter.SmoothBursty

Enclosing class:
SmoothRateLimiter

static final class SmoothRateLimiter.SmoothBursty extends SmoothRateLimiter
This implements a "bursty" RateLimiter, where storedPermits are translated to zero throttling. The maximum number of permits that can be saved (when the RateLimiter is unused) is defined in terms of time, in this sense: if a RateLimiter is 2qps, and this time is specified as 10 seconds, we can save up to 2 * 10 = 20 permits.
  • Field Details

    • maxBurstSeconds

      final double maxBurstSeconds
      The work (permits) of how many seconds can be saved up if this RateLimiter is unused?
  • Constructor Details

  • Method Details

    • doSetRate

      void doSetRate(double permitsPerSecond, double stableIntervalMicros)
      Specified by:
      doSetRate in class SmoothRateLimiter
    • storedPermitsToWaitTime

      long storedPermitsToWaitTime(double storedPermits, double permitsToTake)
      Description copied from class: SmoothRateLimiter
      Translates a specified portion of our currently stored permits which we want to spend/acquire, into a throttling time. Conceptually, this evaluates the integral of the underlying function we use, for the range of [(storedPermits - permitsToTake), storedPermits].

      This always holds: 0 <= permitsToTake <= storedPermits

      Specified by:
      storedPermitsToWaitTime in class SmoothRateLimiter
    • coolDownIntervalMicros

      double coolDownIntervalMicros()
      Description copied from class: SmoothRateLimiter
      Returns the number of microseconds during cool down that we have to wait to get a new permit.
      Specified by:
      coolDownIntervalMicros in class SmoothRateLimiter