Class RedissonRateLimiter

java.lang.Object
org.oxerr.rescu.ext.ratelimiter.redisson.RedissonRateLimiter
All Implemented Interfaces:
RateLimiter

public class RedissonRateLimiter extends Object implements RateLimiter
  • Constructor Summary

    Constructors
    Constructor
    Description
    RedissonRateLimiter(org.redisson.api.RedissonClient redisson, String name)
     
    RedissonRateLimiter(org.redisson.api.RRateLimiter rateLimiter)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Acquires a permit from this RateLimiter, blocking until one is available.
    org.redisson.api.RRateLimiter
     
    void
    setRate(org.redisson.api.RateType mode, long rate, long rateInterval, org.redisson.api.RateIntervalUnit rateIntervalUnit)
    Updates RateLimiter's state and stores config to Redis server.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RedissonRateLimiter

      public RedissonRateLimiter(org.redisson.api.RRateLimiter rateLimiter)
    • RedissonRateLimiter

      public RedissonRateLimiter(org.redisson.api.RedissonClient redisson, String name)
  • Method Details

    • setRate

      public void setRate(org.redisson.api.RateType mode, long rate, long rateInterval, org.redisson.api.RateIntervalUnit rateIntervalUnit)
      Updates RateLimiter's state and stores config to Redis server.
      Parameters:
      mode - - rate mode
      rate - - rate
      rateInterval - - rate time interval
      rateIntervalUnit - - rate time interval unit
    • acquire

      public void acquire()
      Description copied from interface: RateLimiter
      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.

      Specified by:
      acquire in interface RateLimiter
    • getRateLimiter

      public org.redisson.api.RRateLimiter getRateLimiter()