Class ItemExponentialFailureRateLimiter<T>

java.lang.Object
io.micronaut.kubernetes.client.openapi.operator.workqueue.ratelimiter.ItemExponentialFailureRateLimiter<T>
Type Parameters:
T - item type
All Implemented Interfaces:
RateLimiter<T>

public class ItemExponentialFailureRateLimiter<T> extends Object implements RateLimiter<T>
Rate limiter which calculates delay based on the number of failures: baseDelay*2number-of-failures.

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

  • Constructor Details

    • ItemExponentialFailureRateLimiter

      public ItemExponentialFailureRateLimiter(Duration baseDelay, Duration maxDelay)
  • Method Details

    • when

      public Duration when(T item)
      Description copied from interface: RateLimiter
      Decides how long an item should wait before adding it back to the queue.
      Specified by:
      when in interface RateLimiter<T>
      Parameters:
      item - an item that should wait
      Returns:
      how long an item should wait before adding it back to the queue
    • forget

      public void forget(T item)
      Description copied from interface: RateLimiter
      Indicates that an item is finished being retried (failed or succeeded).
      Specified by:
      forget in interface RateLimiter<T>
      Parameters:
      item - an item to remove from internal tracking
    • numRequeues

      public int numRequeues(T item)
      Description copied from interface: RateLimiter
      Returns a number of failures that the item has had.
      Specified by:
      numRequeues in interface RateLimiter<T>
      Parameters:
      item - an item
      Returns:
      number of failures that the item has had
    • reset

      public void reset()
      Description copied from interface: RateLimiter
      Resets the rate limiter.
      Specified by:
      reset in interface RateLimiter<T>