Class LimitRetryAfter

java.lang.Object
com.maybeitssquid.retry.LimitRetryAfter
All Implemented Interfaces:
Predicate<jakarta.servlet.http.HttpServletResponse>

public class LimitRetryAfter extends Object implements Predicate<jakarta.servlet.http.HttpServletResponse>
Predicate to prevent a retry if there is a Retry-After header that specifies too long a wait interval.
  • Constructor Details

    • LimitRetryAfter

      public LimitRetryAfter(Duration maximum, Function<jakarta.servlet.http.HttpServletResponse,Optional<Duration>> parser)
      Creates a predicate to limit intervals requested by an HTTP Retry-After header.
      Parameters:
      maximum - the maximum wait interval
      parser - the parser for the headers
  • Method Details

    • maximum

      public static LimitRetryAfter maximum(Duration limit)
      Creates a predicate to limit intervals requested by an HTTP Retry-After header, using an extended parser.
      Parameters:
      limit - the maximum wait interval
      Returns:
      a limiter predicate
      See Also:
    • maximum

      public static LimitRetryAfter maximum(long milliseconds)
      Convenience wrapper to express the limit in milliseconds.
      Parameters:
      milliseconds - the limit in milliseconds
      Returns:
      a limiter predicate
      See Also:
    • getMaximum

      public Duration getMaximum()
      Gets the maximum wait interval allowed
      Returns:
      the maximum wait interval allowed
    • test

      public boolean test(jakarta.servlet.http.HttpServletResponse t)
      Tests whether there is a Retry-After header that would exceed the limit.
      Specified by:
      test in interface Predicate<jakarta.servlet.http.HttpServletResponse>
      Parameters:
      t - the HTTP response to check for a Retry-After header
      Returns:
      false if there is a Retry-After header and the requested duration would exceed the limit