DefaultRateLimiter

constructor(config: RateLimiterConfig, onRateLimited: suspend (Duration) -> Unit = {}, timeSource: TimeSource = SystemTimeSource)

Parameters

config

The configuration for this rate limiter, specifying the maximum number of calls per period and the timeout behavior.

onRateLimited

A suspendable lambda that is invoked when a call is rate-limited and forced to wait. It receives the duration of the wait as a parameter. This is called before the wait begins.

timeSource

A source for the current time, used for calculating token refills. Defaults to the system clock.