Interface RateLimiter

  • All Superinterfaces:
    java.lang.AutoCloseable, java.io.Serializable
    All Known Implementing Classes:
    EnvoyRateLimiter

    public interface RateLimiter
    extends java.io.Serializable, java.lang.AutoCloseable
    A RateLimiter allows to fetch permits from a rate limiter service and blocks execution when the rate limit is exceeded.

    Implementations must be Serializable as they are passed to workers.

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      boolean allow​(int permits)
      Blocks until the specified number of permits are acquired and returns true if the request was allowed or false if the request was rejected.
      • Methods inherited from interface java.lang.AutoCloseable

        close
    • Method Detail

      • allow

        boolean allow​(int permits)
               throws java.io.IOException,
                      java.lang.InterruptedException
        Blocks until the specified number of permits are acquired and returns true if the request was allowed or false if the request was rejected.
        Parameters:
        permits - Number of permits to acquire.
        Returns:
        true if the request was allowed, false if it was rejected (and retries exceeded).
        Throws:
        java.io.IOException - if there is an error communicating with the rate limiter service.
        java.lang.InterruptedException - if the thread is interrupted while waiting.