module Mosquito::RateLimiter

Defined in:

mosquito/rate_limiter.cr

Instance Method Summary

Instance Method Detail

def increment_run_count : Nil #

Increments the run counter.


[View source]
def increment_run_count_by : Int32 #

How much the run counter should be incremented by. Implemented as a dynamic method so that it can easily be calculated by some other metric, eg api calls to a third party library.


[View source]
def maxed_rate_for_window? : Bool #

Has the run count exceeded the ceiling for the current window?


[View source]
def metadata : Metadata #

Storage hash for rate limit data.


[View source]
def rate_limited? : Bool #

Should this job be cancelled? If not, update the rate limit metadata.


[View source]
def reschedule_interval(retry_count : Int32) : Time::Span #

Configure the reschedule interval so that the job_run is not run again until it should be allowed through the rate limiter.


[View source]
def rescheduleable?(retry_count : Int32) : Bool #

Configure the rescheduler to always retry if a job is rate limited.


[View source]
def update_window_start : Nil #

Resets the run count and logs the start of window.


[View source]
def window_expires_at : Time | Nil #

When does the current rate limit window expire? Returns nil if the window is already expired.


[View source]
def window_start : Time | Nil #

Calculates the start of the rate limit window.


[View source]