rate_limiter

A rate limiter implementation
HEAD Latest release released
z64/rate_limiter
5 1
Zac Nowicki

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
rate_limiter:
  github: z64/rate_limiter
  
License MIT
Crystal 0.34.0

Authors

Dependencies 0

Development Dependencies 0

Last synced .
search fire star recently