Interface TimeWindow


public interface TimeWindow
  • Method Summary

    Modifier and Type
    Method
    Description
    static TimeWindow
    createFixed(Stopwatch stopwatch, int maxInvocations, long timeWindowInMillis, long minSpacingInMillis)
     
    static TimeWindow
    createRolling(Stopwatch stopwatch, int maxInvocations, long timeWindowInMillis, long minSpacingInMillis)
     
    static TimeWindow
    createSmooth(Stopwatch stopwatch, int maxInvocations, long timeWindowInMillis, long minSpacingInMillis)
     
    long
    Records an invocation attempt.
  • Method Details

    • record

      long record()
      Records an invocation attempt. A result of zero means that the invocation should be permitted. A positive result means that the invocation should be rejected and the returned number is the minimum number of milliseconds after which retrying makes sense. A negative result means that the invocation should be rejected, but the "retry after" information is unknown.
      Returns:
      zero when the invocation should be permitted, positive or negative when the invocation should be rejected
    • createFixed

      static TimeWindow createFixed(Stopwatch stopwatch, int maxInvocations, long timeWindowInMillis, long minSpacingInMillis)
    • createRolling

      static TimeWindow createRolling(Stopwatch stopwatch, int maxInvocations, long timeWindowInMillis, long minSpacingInMillis)
    • createSmooth

      static TimeWindow createSmooth(Stopwatch stopwatch, int maxInvocations, long timeWindowInMillis, long minSpacingInMillis)