{"repo":"viafintech/gcra-ruby","free":true,"listed":false,"github":"https://github.com/viafintech/gcra-ruby","clone":"git clone https://github.com/viafintech/gcra-ruby.git","description":"Generic cell rate algorithm (leaky bucket) implementation for rate limiting","language":"Ruby","stars":53,"topics":["rate-limiting","redis","ruby-gem"],"license":"MIT","category":"databases-storage","readme_excerpt":"GCRA for Ruby gcra is a Ruby implementation of a generic cell rate algorithm (GCRA), ported from and data-format compatible with the Go implementation throttled. It's useful for rate limiting (e.g. for HTTP requests) and allows weights specified per request. Getting Started gcra currently uses Redis ( = 2.6.12 for EVALSHA, SCRIPT LOAD, SEX with NX and PX) as a data store, although it supports other store implementations. Add to your Gemfile : Create Redis, RedisStore and RateLimiter instances: rate period : Period between two requests, allowed as a sustained rate. Example: 0.1 for 10 requests per second max burst : Number of requests allowed as a burst in addition to the sustained rate. If the burst is used up, one additional request allowed as burst 'comes back' after each rate period where no request was made. Rate limit a request (call this before each request): exceeded : false means the request should be allowed, true means the request would exceed the limit and should be blocked. info : GCRA::RateLimitInfo contains information that might be useful for your API users. It's a Struct with the following fields: - limit : Contains the number of requests that can be made if no previous requests have been made (or they were long enough ago). That's max burst plus one. The latter is necessary so requests are allowed at all when max burst is set to zero. - remaining : The number of remaining requests that can be made immediately, i.e. the remaining burst. - reset after : The tim","default_branch":null,"files":null,"tree":[],"storefront":"/r/viafintech","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/viafintech/gcra-ruby/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}