rate Limit
fun OkHttpClient.Builder.rateLimit(permits: Int, period: Duration = 1.seconds): OkHttpClient.Builder(source)
An OkHttp interceptor that handles rate limiting.
Examples:
permits = 5, period = 1.seconds => 5 requests per second permits = 10, period = 2.minutes => 10 requests per 2 minutes
Since
extension-lib 14
Parameters
permits
Int Number of requests allowed within a period of units.
period
Duration The limiting duration. Defaults to 1.seconds.
fun OkHttpClient.Builder.rateLimit(permits: Int, period: Long = 1, unit: TimeUnit = TimeUnit.SECONDS): OkHttpClient.Builder(source)
Deprecated
Use the version with kotlin.time APIs instead.
An OkHttp interceptor that handles rate limiting.
This uses java.time
APIs and is the legacy method, kept for compatibility reasons with existing extensions.
Examples:
permits = 5, period = 1, unit = seconds => 5 requests per second permits = 10, period = 2, unit = minutes => 10 requests per 2 minutes
Since
extension-lib 13