RateLimit

object RateLimit

Implements the ability wo work with GitHub's rate limit, recognize blocks from previous attempts, wait and retry.

Functions

equals
Link copied to clipboard
open operator fun equals(other: Any?): Boolean
getWaitLength
Link copied to clipboard
private fun getWaitLength(): Long

calculate required wait in ms

hashCode
Link copied to clipboard
open fun hashCode(): Int
isLimitReached
Link copied to clipboard
private fun isLimitReached(): Boolean

Maintain and check a rate-limit

notifyHttpResponse
Link copied to clipboard
fun notifyHttpResponse(response: HttpURLConnection)

http responses should be passed to this so the actual rate limit window can be evaluated and used. The very first response and all 403 ones are good candidates if they can be expected to contain GitHub's rate limit headers.

toString
Link copied to clipboard
open fun toString(): String
waitForLimit
Link copied to clipboard
fun waitForLimit(): Boolean

If rate limit in effect, sleep long enough to allow next request.

Properties

account
Link copied to clipboard
private var account: Int = 0
firstRequest
Link copied to clipboard
private var firstRequest: Long = 0L
intervalInMilliSeconds
Link copied to clipboard
const val intervalInMilliSeconds: Long = 60000L
maxRequestsPerInterval
Link copied to clipboard
const val maxRequestsPerInterval: Int = 10
maxWaitLoop
Link copied to clipboard
private const val maxWaitLoop: Int = 3
millis
Link copied to clipboard
private val millis: Long

Sources

jvm source
Link copied to clipboard