Interface TimeWindow
-
public interface TimeWindow
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static TimeWindowcreateFixed(Stopwatch stopwatch, int maxInvocations, long timeWindowInMillis, long minSpacingInMillis)static TimeWindowcreateRolling(Stopwatch stopwatch, int maxInvocations, long timeWindowInMillis, long minSpacingInMillis)static TimeWindowcreateSmooth(Stopwatch stopwatch, int maxInvocations, long timeWindowInMillis, long minSpacingInMillis)longrecord()Records an invocation attempt.
-
-
-
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)
-
-