Class RateLimitChecker.LiteralValue
- java.lang.Object
-
- org.kohsuke.github.RateLimitChecker
-
- org.kohsuke.github.RateLimitChecker.LiteralValue
-
- Enclosing class:
- RateLimitChecker
public static class RateLimitChecker.LiteralValue extends RateLimitChecker
ARateLimitChecker
with a simple number as the limit.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.kohsuke.github.RateLimitChecker
RateLimitChecker.LiteralValue
-
-
Field Summary
-
Fields inherited from class org.kohsuke.github.RateLimitChecker
NONE
-
-
Constructor Summary
Constructors Constructor Description LiteralValue(int sleepAtOrBelow)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
checkRateLimit(GHRateLimit.Record record, long count)
Decides whether the current request exceeds the allowed "rate limit" budget.-
Methods inherited from class org.kohsuke.github.RateLimitChecker
sleepUntilReset
-
-
-
-
Method Detail
-
checkRateLimit
protected boolean checkRateLimit(GHRateLimit.Record record, long count) throws InterruptedException
Description copied from class:RateLimitChecker
Decides whether the current request exceeds the allowed "rate limit" budget. If this determines the rate limit will be exceeded, this method should sleep for some amount of time and must returntrue
. Implementers are free to choose whatever strategy they prefer for what is considered to exceed the budget and how long to sleep.The caller of this method figures out which
GHRateLimit.Record
applies for the current request and provides it to this method.As long as this method returns
true
it is guaranteed thatGitHubRateLimitChecker
will retrieve updated rate limit information and call this method again withcount
incremented by one. When this checker returnsfalse
, the callingGitHubRateLimitChecker
will let the request continue.Rate limit reset times are only accurate to the second. Trying to sleep to exactly the reset time could result in requests being sent before the new rate limit was available. For this reason, if this method returned
true
at least once for a particular request,GitHubRateLimitChecker
may choose to sleep for some small additional between calls and before letting the request continue.- Overrides:
checkRateLimit
in classRateLimitChecker
- Parameters:
record
- the currentGHRateLimit.Record
to check against.count
- the number of times in a row this method has been called for the current request- Returns:
false
if the current request does not exceed the allowed budget,true
if the current request exceeded the budget.- Throws:
InterruptedException
- if the thread is interrupted while sleeping
-
-