ExclusionRequestRateLimiter

class ExclusionRequestRateLimiter(val clock: Clock = Clock.System) : AbstractRateLimiter(source)

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.

Parameters

clock

a Clock used for calculating suspension times, present for testing purposes.

Constructors

Link copied to clipboard
constructor(clock: Clock = Clock.System)

Properties

Link copied to clipboard

Functions

Link copied to clipboard
open suspend override fun await(request: Request<*, *>): RequestToken

Awaits all active rate limits for the request, returning a RequestToken used to process the result of the request.

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.