RateLimitProviderConfig

A config for RateLimit provider inside RateLimiterConfig.

Constructors

Link copied to clipboard
constructor(name: RateLimitName)

Functions

Link copied to clipboard

Sets a function that modifies response headers. By default, these headers will be added:

Link copied to clipboard
fun rateLimiter(provider: (call: ApplicationCall, key: Any) -> RateLimiter)

Sets RateLimit for this provider based on ApplicationCall and key of this request.

fun rateLimiter(limit: Int, refillPeriod: Duration, initialSize: Int = limit, clock: () -> Long = { getTimeMillis() })

Sets RateLimit for this provider

Link copied to clipboard
fun requestKey(block: suspend (ApplicationCall) -> Any)

Sets a function that returns a key for a request. Requests with different keys will have independent Rate-Limits. Keys should have good equals and hashCode implementations. By default, the key is a Unit, so all requests share the same Rate-Limit.

Link copied to clipboard
fun requestWeight(block: suspend (ApplicationCall, key: Any) -> Int)

Sets a function that returns a weight of a request. Weight is used to calculate how many tokens are consumed by a request. By default, weight is always 1.