Class RateLimitedConsumer<T>

java.lang.Object
com.atlassian.confluence.util.misc.RateLimitedConsumer<T>
All Implemented Interfaces:
Consumer<T>

public class RateLimitedConsumer<T> extends Object implements Consumer<T>
Ignores calls to the wrapped consumer if the same key has been called within the minimum interval. Thread safe.
Since:
9.3
  • Constructor Details

    • RateLimitedConsumer

      public RateLimitedConsumer(Consumer<T> callback, long minimumIntervalMs)
      Creates a new rate limited consumer.
      Parameters:
      callback - the consumer to call
      minimumIntervalMs - the minimum interval between calls in milliseconds
  • Method Details

    • accept

      public void accept(T key)
      Specified by:
      accept in interface Consumer<T>