module Mosquito::RateLimiter

Defined in:

mosquito/rate_limiter.cr

Instance Method Summary

Instance Method Detail

def increment_run_count : Nil #

Increments the run counter.


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.


def maxed_rate_for_window? : Bool #

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


def metadata : Metadata #

Storage hash for rate limit data.


def rate_limited? : Bool #

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


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.


def rescheduleable?(retry_count : Int32) : Bool #

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


def update_window_start : Nil #

Resets the run count and logs the start of window.


def window_expires_at : Time | Nil #

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


def window_start : Time | Nil #

Calculates the start of the rate limit window.