A rate limiter implementation in Crystal
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
spec
src
.editorconfig
.gitignore
.travis.yml
LICENSE
README.md
shard.yml

README.md

rate_limiter

A utility class for rate limiting, ported from @meew0's implementation in discordrb

Installation

Add this to your application's shard.yml:

dependencies:
  rate_limiter:
    github: z64/rate_limiter

Usage

require "rate_limiter"

# Make a new rate limiter that will limit based on string "usernames"
limiter = RateLimiter(String).new

# Create a bucket that allows 3 requests per second
limiter.bucket(:foo, 3_u32, 1.seconds)

# Perform a request on "z64"
limiter.rate_limited?(:foo, "z64")

Contributors

  • z64 Zac Nowicki - creator, maintainer