execute

suspend fun <T> execute(permits: Int = 1, block: suspend () -> T): T(source)

Executes an operation with rate limiting.

Waits (suspends) until a token is available, then executes the operation.

Return

The result of the operation

Parameters

permits

Number of permits (tokens) required (default: 1)

block

The operation to execute

Throws

if the operation fails