Package-level declarations

Types

Link copied to clipboard
Link copied to clipboard
value class BucketKey(val value: String)

The unique identifier of this bucket.

Link copied to clipboard
class ExclusionRequestRateLimiter(val clock: Clock = Clock.System) : AbstractRateLimiter

A RequestRateLimiter that handles all requests in sequential order, minimizing the possibility of rate limits. Requests are handled in call order and will suspend to adhere to global and bucket rate limits.

Link copied to clipboard

A RequestRateLimiter that tries to handle requests in a parallel order. Requests are run sequentially per bucket, allowing requests that do not share a common rate limit to run uninterrupted. Requests that share a common bucket are handled in call order and will suspend to adhere to global and bucket rate limits.

Link copied to clipboard
data class RateLimit(val total: Total, val remaining: Remaining)
Link copied to clipboard
value class Remaining(val value: Long)
Link copied to clipboard

A rate limiter that follows Discord's rate limits for the REST api.

Link copied to clipboard
sealed class RequestResponse
Link copied to clipboard
interface RequestToken

A completable token linked to a Request.

Link copied to clipboard
value class Reset(val value: Instant)

The instant when the current bucket gets reset.

Link copied to clipboard
value class Total(val value: Long)

Functions

Link copied to clipboard
inline suspend fun <T> RequestRateLimiter.consume(request: Request<*, *>, consumer: (token: RequestToken) -> T): T

Awaits the rate limits for the request and then runs consumer. Throws an IllegalStateException if the supplied RequestToken was not completed.