All Projects → julienXX → resque-waiting-room

julienXX / resque-waiting-room

Licence: MIT license
Resque plugin that throttles your jobs

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to resque-waiting-room

Ratelimiter
C# rate limiting utility
Stars: ✭ 159 (+367.65%)
Mutual labels:  rate-limiting
active scheduler
Resque Scheduling for ActiveJob
Stars: ✭ 72 (+111.76%)
Mutual labels:  resque
jobqueue
Jobqueue manages running and scheduling jobs (think Sidekiq or Resque for Go).
Stars: ✭ 37 (+8.82%)
Mutual labels:  resque
Fastify Rate Limit
A low overhead rate limiter for your routes
Stars: ✭ 179 (+426.47%)
Mutual labels:  rate-limiting
Redis rate
Rate limiting for go-redis
Stars: ✭ 248 (+629.41%)
Mutual labels:  rate-limiting
taskinator
A simple orchestration library for running complex processes or workflows in Ruby
Stars: ✭ 25 (-26.47%)
Mutual labels:  resque
Aspnetcoreratelimit
ASP.NET Core rate limiting middleware
Stars: ✭ 2,199 (+6367.65%)
Mutual labels:  rate-limiting
flood-protection
Flood protection for realtime applications
Stars: ✭ 19 (-44.12%)
Mutual labels:  rate-limiting
rocketjob
Ruby's missing background and batch processing system
Stars: ✭ 281 (+726.47%)
Mutual labels:  resque
resque exporter
An exporter of Prometheus for resque's status.
Stars: ✭ 12 (-64.71%)
Mutual labels:  resque
Rate Limit
🚔 General purpose rate limiter implementation.
Stars: ✭ 193 (+467.65%)
Mutual labels:  rate-limiting
Slidingwindow
Golang implementation of Sliding Window Algorithm for distributed rate limiting.
Stars: ✭ 227 (+567.65%)
Mutual labels:  rate-limiting
flume
A blazing fast job processing system backed by GenStage & Redis.
Stars: ✭ 37 (+8.82%)
Mutual labels:  rate-limiting
Laravel Rate Limited Job Middleware
A job middleware to rate limit jobs
Stars: ✭ 166 (+388.24%)
Mutual labels:  rate-limiting
gentle-force
Brute-force, error and request rate limiting
Stars: ✭ 45 (+32.35%)
Mutual labels:  rate-limiting
Nginxconfig.io
⚙️ NGINX config generator on steroids 💉
Stars: ✭ 14,983 (+43967.65%)
Mutual labels:  rate-limiting
gcra-ruby
Generic cell rate algorithm (leaky bucket) implementation for rate limiting
Stars: ✭ 49 (+44.12%)
Mutual labels:  rate-limiting
EnumerableAsyncProcessor
Process Multiple Asynchronous Tasks in Various Ways - One at a time / Batched / Rate limited / Concurrently
Stars: ✭ 84 (+147.06%)
Mutual labels:  rate-limiting
p-ratelimit
Promise-based utility to make sure you don’t call rate-limited APIs too quickly.
Stars: ✭ 49 (+44.12%)
Mutual labels:  rate-limiting
zlimiter
A toolkit for rate limite,support memory and redis
Stars: ✭ 17 (-50%)
Mutual labels:  rate-limiting

Resque Waiting Room

A Resque plugin. Requires Resque >= 1.19 and a >= 1.9 Ruby (MRI, JRuby or Rubinius).

If you want to limit the number of performs of a job for a given period, extend it with this module.

Installation

Add this line to your application's Gemfile:

gem 'resque-waiting-room'

And then execute:

$ bundle

Or install it yourself as:

$ gem install resque-waiting-room

Usage

Example -- 10 jobs processed every 30 seconds max

require 'resque/plugins/waiting_room'

class UpdateDataFromExternalAPI
  extend Resque::Plugins::WaitingRoom

  # This job can be performed 10 times every 30 seconds
  can_be_performed times: 10, period: 30

  def self.perform(repo_id)
    blah
  end
end

If 10 UpdateDataFromExternalAPI jobs have been performed in 20 seconds, for the next 10 seconds UpdateDataFromExternalAPI jobs will be placed in the waiting_room queue and processed when possible. When the first 30 seconds are elapsed, the counter is set back to 0 and 10 jobs can be performed again. You got to manually tweak the queue names in your workers though.

Testing

We include a matcher

require 'spec/support/matchers'

describe MyJob do
  it 'is rate limited' do
    MyJob.should be_only_performed(times: 100, period: 300)
  end
end

Run tests with the following command

bundle exec rake

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Thanks to the following people for helping out

  • Thomas Devol @socialchorus for adding the RSpec matcher
  • Max Dunn @maxdunn210 for making me switch Resque 2 specific code in it's own branch
  • Jeff Durand @johnnyiller for the update of has_remaining_performs_key using the latest form set and the fix for a rare ttl bug
  • Tatsuya Takamura @ttakamura for raising the issue on the rare ttl bug
  • Omry Zobel @omryYotpo for allowing some customization of the redis key

Build Status Code Climate

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].