Rubykiq
Sidekiq agnostic enqueuing using Redis.
Sidekiq is a fantastic message processing library which has a simple and stable message format. Rubykiq
aims to be a portable library to push jobs in to Sidekiq with as little overhead as possible whilst having feature parity on Sidekiq::Client
's conventions.
Features / Usage Examples
- Redis has support for alternative drivers, Rubykiq is tested with these in mind. ( eg
:synchrony
) - The
:at
parameter supportsTime
,Date
and anyTime.parse
-able strings. - Pushing multiple and singular jobs has the same interface ( simply nest args )
- Slightly less gem dependecies, and by that I mean
Sidekiq::Client
withoutCelluloid
( which is already very light! )
require "rubykiq"
# will also detect REDIS_URL, REDIS_PROVIDER and REDISTOGO_URL ENV variables
Rubykiq.url = "redis://127.0.0.1:6379"
# alternative driver support ( :ruby, :hiredis, :synchrony )
Rubykiq.driver = :synchrony
# defaults to nil
Rubykiq.namespace = "background"
# uses "default" queue unless specified
Rubykiq.push(:class => "Worker", :args => ["foo", 1, :bat => "bar"])
# args are optionally set to empty
Rubykiq.push(:class => "Scheduler", :queue => "scheduler")
# will batch up multiple jobs
Rubykiq.push(:class => "Worker", :args => [["foo"], ["bar"]])
# at param can be a "Time", "Date" or any "Time.parse"-able strings
Rubykiq.push(:class => "DelayedHourMailer", :at => Time.now + 3600)
Rubykiq.push(:class => "DelayedDayMailer", :at => DateTime.now.next_day)
Rubykiq.push(:class => "DelayedMailer", :at => "2013-01-01T09:00:00Z")
# alias based sugar
job = { :class => "Worker" }
Rubykiq << job
Caveats
- It's advised that using Sidekiq::Client's push method when already a dependency is better in most everyday cases
- If you rely on any Sidekiq Middleware, Rubykiq is not aware of them so defaults will not be applied to the job hash.
Build & Dependency Status
Supported Redis Drivers
Supported Ruby Versions
This library aims to support and is tested against the following Ruby implementations:
- Ruby 1.9.2 (drivers: ruby, hiredis, synchrony)
- Ruby 1.9.3 (drivers: ruby, hiredis, synchrony)
- Ruby 2.0.0 (drivers: ruby, hiredis, synchrony)
- JRuby (drivers: ruby)
- Rubinius (drivers: ruby)
Credits
Inspiration:
Cribbed: