0.0
No commit activity in last 3 years
No release in over 3 years
Rescheduler is a library that uses Redis to maintain a task queue of immediate and delayed jobs without polling.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

Rescheduler

Example (pure ruby)

In your jobs.rb

require 'rescheduler'

Rescheduler.job('ring-alarm') do |arg|
  Music.find_by_name(arg[:song]).play
end

Rescheduler.start # This starts the worker infinite loop

To schedule the job

Rescheduler.enqueue(:queue=>'ring-alarm', :song=>'Jingle', :due_in => 600) # Use 10.minutes if using active support

Example (using rescheduler_launch)

In your jobs.rb

job('ring-alarm') do |arg|
  Music.find_by_name(arg[:song]).play
end

start # You need to start your job explicitly

Then launch it

rescheduler_launch worker% jobs.rb

Installation

  gem install rescheduler

Dependency

Features

  1. Based solely on Redis. Can configure connection, db, prefix.
  2. Immediate response time for immediate jobs. (Event machine style, no polling)
  3. CPU idle when there is no job. (Block waiting, no polling)
  4. Light weight and low setup. Queues automatically maintained by workers.
  5. "id" supports querying, overwriting and removing of pending jobs.

TODO later

  1. Testing
  2. Priority of jobs
  3. Edit pending job parameter without changing its position in queue
  4. Producer throttling (max queue length)
  5. Programmable queue priority (handle the tube with most job first?)
  6. Class.perform style of worker definition(?)
  7. Other clients (Java etc.)
  8. Detection and recovery of dead workers
  9. Detection and recovery of "lost" jobs
  10. Allow cherry-picking of jobs from special clients

Non-goals

Known bugs/deficiencies

  • Long immediate queues with unique id: Scanning the queue to delete possible duplicated job can be slow
  • Fast deferred job producers: When deferred job is produced very fast (more than 5/sec) the service of deferred jobs may not find a chance to move any deferred job to immediate queue
  • Job jumping: If job(id:A) is freshly dequeued by a worker while a producer tries to generate the same job with id:A, there is a slight chance that new job parameter will be fetched by the worker that tries to run the old job.

API

Please read the source (not ready for production use yet)

Configuration

Rescheduler.config[:redis_config] # Redis configuration hash (see https://github.com/redis/redis-rb)
Rescheduler.config[:prefix] = '' # Redis key prefix, for namespacing

NOTE: Change prefix will invalidate current jobs.

Other similar tools

  • Resque: Uses polling
  • qless: Uses LUA scripts inside redis server

Worker Documentations

Options

  • --rails, --rails= Specify the rails environment to load before using Rescheduler This is useful for fetching the exact Rails setup for Reschduler for worker processes This will also set the log output to the correct place