Project

rekiq

0.0
No commit activity in last 3 years
No release in over 3 years
There's a lot of open issues
Rekiq extends Sidekiq to allow the scheduling of recurring workers
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

Rekiq

Gem Version Build Status Code Climate Test Coverage Dependency Status

Rekiq is a recurring worker extension for Sidekiq.

Rekiq extends Sidekiq and adds functionality to schedule recurring workers.

Sidekiq is an amazing gem that allows us to execute work asynchronously, or even schedule work to be run at a given time. Now, wouldn't it be nice if it also allowed us to schedule a worker to do recurring work? That's the purpose of rekiq.

For example, rekiq allows you to schedule a worker to repeat the same work every friday at 23:00.

Dependencies

Tested with:

  • ruby 2.2.0, 2.1.1, 2.0.0

  • sidekiq 3.3.3

Installation

Add this line to your application's Gemfile:

gem 'rekiq'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rekiq

Basic usage

  1. Require rekiq after sidekiq:

     require 'sidekiq'
     require 'rekiq'
    
  2. We need a 'schedule' object (responsible for returning the time at which the worker should start) which must respond to method next_occurrence and receives one argument of type Time (more at The schedule object). For our example we'll be using the gem ice_cube (don't forget to require it):

     # define worker as normal
     class ExampleWorker
       include Sidekiq::Worker
    
       def perform(arg1, arg2)
         # Do some work
       end
     end
    
     # create schedule for worker to repeat every friday at 2am
     schedule = IceCube::Schedule.new do |s|
         s.rrule IceCube::Rule.daily.day(:friday).hour_of_day(2)
       end
    
     # now just start your worker
     ExampleWorker.perform_recurringly(schedule, 'argument_1', 'argument_2')
    

And that's it! Now the worker will run every friday as 2am.

You can use your own schedule object, configure worker to schedule before or after work is done, set a margin, and much more! So please feel free to check wiki for more details.

Contributing

  1. Fork it ( https://github.com/junhanamaki/rekiq/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request