1
0
Fork 0
mirror of https://github.com/endofunky/sidetiq.git synced 2022-11-09 13:53:30 -05:00
NO LONGER MAINTAINED Recurring jobs for Sidekiq
Find a file
2013-01-31 18:06:09 +00:00
examples Initial commit. 2013-01-31 17:42:19 +00:00
ext/sidetiq_ext Remove unused typedef. 2013-01-31 17:58:00 +00:00
lib Inherit clock thread priority from Thread.main. 2013-01-31 17:50:37 +00:00
test Initial commit. 2013-01-31 17:42:19 +00:00
.gitignore Initial commit. 2013-01-31 17:42:19 +00:00
.travis.yml Compile C extensions before running tests on Travis. 2013-01-31 18:03:25 +00:00
Gemfile Initial commit. 2013-01-31 17:42:19 +00:00
LICENSE Initial commit. 2013-01-31 17:42:19 +00:00
Rakefile Initial commit. 2013-01-31 17:42:19 +00:00
README.md Add Travis build status to README. 2013-01-31 18:06:09 +00:00
sidetiq.gemspec Initial commit. 2013-01-31 17:42:19 +00:00

Sidetiq

Build Status

Recurring jobs for Sidekiq.

DESCRIPTION

Sidetiq provides a simple API for defining recurring workers for Sidekiq.

  • Flexible DSL based on ice_cube
  • High-resolution timer using clock_gettime(3) (or mach_absolute_time() on Apple Mac OS X), allowing for accurate sub-second clock ticks.

DEPENDENCIES

INSTALLATION

The best way to install Sidetiq is with RubyGems:

$ [sudo] gem install sidetiq

If you're installing from source, you can use Bundler to pick up all the gems (more info):

$ bundle install

GETTING STARTED

Defining recurring jobs is simple:

class MyWorker
  include Sidekiq::Worker
  include Sidetiq::Schedulable

  # Every other month on the first monday and last tuesday at 12 o'clock.
  tiq { monthly(2).day_of_week(1 => [1], 2 => [-1]).hour_of_day(12) }
end

It also is possible to define multiple scheduling rules for a worker:

class MyWorker
  include Sidekiq::Worker
  include Sidetiq::Schedulable

  tiq do
    # Every third year in March
    yearly(3).month_of_year(:march)

    # Every fourth year in Februrary
    yearly(2).month_of_year(:februrary)
  end
end

The first time the tiq method is called, Sidetiq will automatically spin up it's clock thread and enqueue jobs for their next occurrence using #perform_at. Note that by default Sidekiq only polls every 15 seconds.

CONFIGURATION

Sidetiq.configure do |config|
  # Thread priority of the clock thread (default: Thread.main.priority as
  # defined when Sidetiq is loaded)
  config.priority = 2

  # Clock tick resolution in seconds (default: 0.2)
  config.resolution = 0.5
end

CONSIDERATIONS

If workers are spread across multiple machines multiple jobs might be enqueued at the same time. This can be avoided by using a locking library for Sidekiq, such as sidekiq-unique-jobs.

CONTRIBUTE

If you'd like to contribute to Sidetiq, start by forking my repo on GitHub:

http://github.com/tobiassvn/sidetiq

To get all of the dependencies, install the gem first. The best way to get your changes merged back into core is as follows:

  1. Clone down your fork
  2. Create a thoughtfully named topic branch to contain your change
  3. Write some code
  4. Add tests and make sure everything still passes by running rake
  5. If you are adding new functionality, document it in the README
  6. Do not change the version number, I will do that on my end
  7. If necessary, rebase your commits into logical chunks, without errors
  8. Push the branch up to GitHub
  9. Send a pull request to the tobiassvn/sidetiq project.

LICENSE

Sidetiq is released under the MIT License. See LICENSE for further details.