Interface TimeWindow


  • public interface TimeWindow
    • Method Detail

      • 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)