LinearRateLimiter

class LinearRateLimiter(limitersSettings: Map<UUID, Pair<Long, Duration>>, purgeHitSize: Int, purgeHitDuration: Duration, nowProvider: () -> Instant, initialSize: Int)

Linear implementation of the rate limiting.

Constructors

Link copied to clipboard
fun LinearRateLimiter(limitersSettings: Map<UUID, Pair<Long, Duration>>, purgeHitSize: Int = DEFAULT_PURGE_HIT_SIZE, purgeHitDuration: Duration = DEFAULT_PURGE_HIT_DURATION, nowProvider: () -> Instant = { Instant.now() }, initialSize: Int = DEFAULT_INITIAL_CACHE_SIZE)

Functions

Link copied to clipboard
fun processRequest(limitId: UUID, key: String): Long?

Logs request attempt from the key with limiter limitId.

Sources

Link copied to clipboard