Class RateLimit

  • All Implemented Interfaces:

    
    public final class RateLimit
    
                        

    Rate limiting which works as follows:

    • must be at least defaultMinInterval gap between the requests

    • no more than maxRequests requests within the interval

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final Boolean accept(Instant now, Duration minInterval) Return true if the request should be accepted and false otherwise.
      final Boolean accept(Instant now) Return true if the request should be accepted and false otherwise.
      final Boolean accept() Return true if the request should be accepted and false otherwise.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • accept

        @JvmOverloads() final Boolean accept(Instant now, Duration minInterval)

        Return true if the request should be accepted and false otherwise. now is the current time, if not provided clock.instant() is used. minInterval can be specified per accept call to support varying minimum intervals (e.g., based on round-trip times).

      • accept

        @JvmOverloads() final Boolean accept(Instant now)

        Return true if the request should be accepted and false otherwise. now is the current time, if not provided clock.instant() is used. minInterval can be specified per accept call to support varying minimum intervals (e.g., based on round-trip times).

      • accept

        @JvmOverloads() final Boolean accept()

        Return true if the request should be accepted and false otherwise. now is the current time, if not provided clock.instant() is used. minInterval can be specified per accept call to support varying minimum intervals (e.g., based on round-trip times).