module RateLimiter::LimiterLike

Overview

Defines the API for a rate-limiter-like instance.

Direct including types

Defined in:

rate_limiter.cr

Instance Method Summary

Instance Method Detail

abstract def get(max_wait : Time::Span) : Token | Timeout #

Returns a Token if one is available within max_wait time, otherwise it returns a Timeout. Blocking.


abstract def get : Token #

Returns a Token as soon as available. Blocking.


def get!(max_wait : Time::Span) : Token #

Raises RateLimiter::Timeout if no token is available after the given time span. Blocking for at most a max_wait duration.


def get! : Token #

Raises RateLimiter::Timeout if no token is available at call time. Non-blocking.


def get? : Token? #

Returns nil if no token is available at call time. Non-blocking.