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 | Nil get?

Constructor Detail

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

[View source]

Instance Method Detail

def bucket : Channel(Nil) #

[View source]
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.


[View source]
def get : Token #
Description copied from module RateLimiter::LimiterLike

Returns a Token as soon as available. Blocking.


[View source]
def rate : Float64 #

[View source]