Class RequestRateLimiter

  • Direct Known Subclasses:
    QueryRateLimiter

    @ThreadSafe
    public class RequestRateLimiter
    extends Object
    Handles rate limiting for a specific request type.

    The control flow is as follows: Handle request -- Check if slot is available -- If available, acquire slot and proceed -- else reject the same.

    • Constructor Detail

      • RequestRateLimiter

        public RequestRateLimiter​(RateLimiterConfig rateLimiterConfig)
    • Method Detail

      • allowSlotBorrowing

        public RequestRateLimiter.SlotReservation allowSlotBorrowing()
                                                              throws InterruptedException
        Whether to allow another request type to borrow a slot from this request rate limiter. Typically works fine if there is a relatively lesser load on this request rate limiter's type compared to the others (think of skew).
        Returns:
        returns a metadata object for the acquired slot, if acquired. If the slot was not acquired, returns a metadata object with a null pool.
        Throws:
        InterruptedException
        WARNING: This API is experimental and might change in incompatible ways in the next release.
        -- Can cause slots to be blocked if a request borrows a slot and is itself long lived.