class

Sellia::Server::RateLimiter

Inherits Reference / Object

Token bucket rate limiter with sliding window

Constructors

new(config : Config = Config.new)
Source

Instance methods

allow?(key : String, cost : Float64 = 1.0) : Bool

Check if request is allowed and consume a token

Source
config
Source
config=(config : Config)
Source
remaining(key : String) : Float64

Get remaining tokens for a key

Source
reset(key : String)

Reset rate limit for a key

Source
size

Get number of tracked keys

Source

Nested types