class RateLimiter::Limiter

Overview

A rate limiter erogating tokens at the specified rate.

This is powered by the token bucket algorithm.

Included Modules

Defined in:

rate_limiter.cr

Constructors

Instance Method Summary

Instance methods inherited from module RateLimiter::LimiterLike

get(max_wait : Time::Span) : Token | Timeout
get : Token
get
, get!(max_wait : Time::Span) : Token
get! : Token
get!
, get? : Token? get?

Constructor Detail

def self.new(rate : Float64, max_burst : Int32 = 1) #

Instance Method Detail

def bucket : Channel(Nil) #

def get(max_wait : Time::Span) : Token | Timeout #
Description copied from module RateLimiter::LimiterLike

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


def get : Token #
Description copied from module RateLimiter::LimiterLike

Returns a Token as soon as available. Blocking.


def rate : Float64 #