AbstractIntervalRateLimiter

abstract class AbstractIntervalRateLimiter(val limit: Int, val interval: Duration) : IntervalRateLimiter(source)

Abstract base class for implementing IntervalRateLimiter.

Constructors

Link copied to clipboard
constructor(limit: Int, interval: Duration)

Properties

Link copied to clipboard
override val interval: Duration

The Duration of each interval.

Link copied to clipboard
override val limit: Int

The maximum number of consume invocations allowed for each interval.

Functions

Link copied to clipboard
suspend override fun consume()

Acquires a permit for a single action. Suspends until the next interval if limit permits have already been acquired in the current interval.

Link copied to clipboard
inline suspend fun <T> RateLimiter.consume(action: () -> T): T

Acquires a permit for a single action. Suspends if necessary until the permit would not exceed the maximum frequency of permits.