Storage

interface Storage

RateLimit uses a defined storage provider implementing this interface to persist the request information used for rate limiting. If you use a blocking database, you should wrap your calls inside withContext.

Types

Link copied to clipboard
interface Requested

Holder for the previous stored request information.

Functions

Link copied to clipboard
abstract suspend fun getOrNull(host: String): Storage.Requested?

Return the information about previous requests for this host, or null, if not found.

Link copied to clipboard
abstract suspend fun remove(host: String)

Remove all request information for this host.

Link copied to clipboard
abstract suspend fun set(host: String, trial: Int, lastRequest: Instant)

Set the current request information for this host. counts the previous trials, while lastRequest represents the time of the last request.

Properties

Link copied to clipboard
abstract val clock: Clock

The clock for creating a Instant.