module Mosquito::RateLimiter::ClassMethods

Defined in:

mosquito/rate_limiter.cr

Instance Method Summary

Instance Method Detail

def metadata : Metadata #

Provides an instance of the metadata store used to track rate limit stats.


def rate_limit_key #

Resolves the key used to index the metadata store for this test.


def rate_limit_stats : NamedTuple #

Statistics about the rate limiter, including both the configuration parameters and the run counts.


def throttle(*, limit : Int32 = 1, per : Time::Span = 1.second, increment = 1, key = self.name.underscore) #

Configures rate limiting for this job.

limit and per are used to control the run count and the window duration. Defaults to a limit of 1 run per second.

increment is used to indicate how many "hits" against a single job is worth. Defaults to 1.

key is used to combine rate limiting functions across multiple jobs.