call

inline suspend fun <R> call(key: Key, permits: Int = 1, timeout: Duration = config.baseTimeoutDuration, block: Supplier<R>): R(source)

Decorates a Supplier with a rate limiter based on the provided key.

Parameters

key

The key used to identify the rate limiter.

permits

The number of permits required to execute the function.

timeout

The duration to wait for permits to be available.

block

The suspending function to decorate.

Throws

if the coroutine is cancelled while waiting for the permits to be available.

if the request is rejected due to the queue being full or the timeout for acquiring permits has expired.