rate_limiter
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