Skip to content

erniedeferia/delayed_job_recurring_mongoid

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

delayed_job_recurring_mongoid

This gem was forked from https://github.com/amitree/delayed_job_recurring in order to convert the code to support Mongoid. The remaining text in this file is the original.

Extends delayed_job_mongoid to support recurring jobs.

Usage

Add it to your Gemfile:

gem 'delayed_job_recurring'

Then define a task class. We like the concept of interactors, so we put our task classes in app/interactors. You could also put them in lib or even app/models.

class MyTask
  include Delayed::RecurringJob
  run_every 1.day
  run_at '11:00am'
  timezone 'US/Pacific'
  def perform
    # Do some work here!
  end
end

And schedule it. In a rails app, you might put this in an initializer:

MyTask.schedule! # run every day at 11am Pacific time (accounting for daylight savings)

Advanced usage

Passing options to schedule

MyTask.schedule(run_at: '12:00')

Running at multiples times each day

MyTask.schedule(run_every: 1.day, run_at: ['11:00', '6:00pm']

Running on specific days of the week

MyTask.schedule(run_every: 1.week, run_at: ['sunday 8:00am', 'wednesday 8:00am'])

Thanks!

Many thanks to @ginjo and @kares for their work! This code was derived from https://gist.github.com/ginjo/3688965.

About

Extends delayed_job_mongoid to support recurring jobs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%