IntervalRateLimiter

fun IntervalRateLimiter(limit: Int, interval: Duration, timeSource: TimeSource = TimeSource.Monotonic): IntervalRateLimiter(source)

Creates an implementation of IntervalRateLimiter that uses a TimeSource for measuring intervals.

Parameters

limit

The maximum number of consume invocations allowed for each interval.

interval

The Duration of each interval.

timeSource

The TimeSource for measuring intervals, TimeSource.Monotonic by default.


Creates an implementation of IntervalRateLimiter that uses a Clock for measuring intervals.

Parameters

limit

The maximum number of consume invocations allowed for each interval.

interval

The Duration of each interval.

clock

The Clock for measuring intervals.