class Srcom::RateLimiter
- Srcom::RateLimiter
- Reference
- Object
Overview
This keeps track of the requests being made the speedrun.com API, making sure that the rate limit
isn't exceeded.
To account for slight inaccuracies an additional #backoff_time
(which defaults to 1 second) can
be specified. This is added to the time that is needed at minimum to be allowed another request.
Defined in:
srcr/rate_limiter.crConstant Summary
-
Log =
Srcom::Log.for("rate_limit")
Constructors
-
.new(backoff_time : Float64 = 1)
Makes a new
RateLimiter
with the given backoff_time in seconds.
Instance Method Summary
- #backoff_time : Float64
- #backoff_time=(backoff_time : Float64)
-
#check_rate_limit(endpoint : String)
Ensures the rate limit is not currently being hit.
-
#global_rate_limit_exceeded
Waits until the oldest request occurred 60 seconds ago + twice the usual backoff time.
Constructor Detail
Makes a new RateLimiter
with the given backoff_time in seconds.
Instance Method Detail
Ensures the rate limit is not currently being hit.
NOTE endpoint is purely for logging purposes.
Waits until the oldest request occurred 60 seconds ago + twice the usual backoff time.
NOTE This only gets called if this RateLimiter
fails, the rate limit gets exceeded, and
speedrun.com returns error code 420.