Class DefaultRateLimitingQueue<T>

Type Parameters:
T - item type
All Implemented Interfaces:
DelayingQueue<T>, RateLimitingQueue<T>, WorkQueue<T>

public class DefaultRateLimitingQueue<T> extends DefaultDelayingQueue<T> implements RateLimitingQueue<T>
The default rate limiting queue implementation.

The code has been copied from the official client and modified: DefaultRateLimitingQueue

  • Constructor Details

    • DefaultRateLimitingQueue

      public DefaultRateLimitingQueue(ExecutorService waitingWorker)
    • DefaultRateLimitingQueue

      public DefaultRateLimitingQueue(ExecutorService waitingWorker, RateLimiter<T> rateLimiter)
  • Method Details

    • numRequeues

      public int numRequeues(T item)
      Description copied from interface: RateLimitingQueue
      Returns back how many times the item was requeued.
      Specified by:
      numRequeues in interface RateLimitingQueue<T>
      Parameters:
      item - specific item
      Returns:
      number of times the item was requeued
    • forget

      public void forget(T item)
      Description copied from interface: RateLimitingQueue
      Indicates that an item is finished being retried. Doesn't matter whether it is for perm failing or for success, we'll stop the rate limiter from tracking it. This only clears the `rateLimiter`, you still have to call `Done` on the queue.
      Specified by:
      forget in interface RateLimitingQueue<T>
      Parameters:
      item - item which is finished being retried
    • addRateLimited

      public void addRateLimited(T item)
      Description copied from interface: RateLimitingQueue
      Adds an item to the work queue after the rate limiter says it is ok.
      Specified by:
      addRateLimited in interface RateLimitingQueue<T>
      Parameters:
      item - item to add
    • shutdown

      public void shutdown()
      Description copied from interface: WorkQueue
      Initiates a shutdown of the work queue. All added items whose processing not started will be ignored and removed from the queue.
      Specified by:
      shutdown in interface WorkQueue<T>
      Overrides:
      shutdown in class DefaultDelayingQueue<T>