src/limiter

Vars

RateLimiter = Limiter(limits: newTable(32))

Procs

proc attempt[L: Limiter](limiter: var L; key: string; maxAttempts: int;
                         callback: CallbackLimiter;
                         timeToWait: TimeInterval = 1.minutes)
Attempts to execute a callback if it's not limited.
proc availableIn[L: Limiter](limiter: var L; keyId: string): Duration
Get the number of seconds until the "key" is accessible again.
proc getHits[L: Limiter](limiter: var L; keyId: string): int
Get number of hits for given keyId
proc getId[L: Limiter](limiter: L; area, key: string): string
proc hit[L: Limiter](limiter: var L; keyId: string)
Increment the counter for a given key for a given decay time.
proc reset[L: Limiter](limiter: var L; keyId: string)
Reset (delete) the limit for given key