rate_limiter

A rate limiter implementation in Crystal

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
Owner
github statistic
  • 4
  • 2
  • 1
  • 0
  • about 1 year ago
  • October 6, 2017
License

MIT License

Links
Synced at

Fri, 14 May 2021 04:52:08 GMT