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 Detail

      • maxBurstSeconds

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

      • 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