Interface IRateLimiter

All Known Implementing Classes:
IRateLimiter.NoOpRateLimiter, RedisBasedRateLimiter, RedisBasedRateLimiterV2, RedisBasedRateLimiterV3

public interface IRateLimiter
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static class 
    No op implementation
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Acquires a permit from this RateLimiter, blocking until one is available.
    void
    acquire(long permits)
    Acquires a specified permits from this RateLimiter, blocking until one is available.
     
    void
    Start rate limiter
    void
    Stop rate limiter
    boolean
    trySetRate(long rate)
    Initializes RateLimiter's state and stores config to Redis server.
  • Method Details

    • debug

      default StringObjectMap debug()
      Returns:
      debug info
    • start

      void start()
      Start rate limiter
    • stop

      void stop()
      Stop rate limiter
    • trySetRate

      boolean trySetRate(long rate)
      Initializes RateLimiter's state and stores config to Redis server. Params: mode – - rate mode rate – - rate rateInterval – - rate time interval rateIntervalUnit – - rate time interval unit Returns: true if rate was set and false otherwise
    • acquire

      void acquire()
      Acquires a permit from this RateLimiter, blocking until one is available. Acquires a permit, if one is available and returns immediately, reducing the number of available permits by one.
    • acquire

      void acquire(long permits)
      Acquires a specified permits from this RateLimiter, blocking until one is available.

      Acquires the given number of permits, if they are available and returns immediately, reducing the number of available permits by the given amount.

      Parameters:
      permits - the number of permits to acquire