resque / resque-scheduler

A light-weight job scheduling system built on top of Resque
MIT License
1.74k stars 480 forks source link

Support Duration for jobs periodicity #605

Open AlexandreKueny opened 7 years ago

AlexandreKueny commented 7 years ago

Instead of doing

name = 'send_emails'
config = {}
config[:class] = 'SendEmail'
config[:args] = 'POC email subject'
config[:every] = ['1h', {first_in: 5.minutes}]
config[:persist] = true
Resque.set_schedule(name, config)

it would be a good idea to be able to do this

config[:every] = [1.hour, {first_in: 5.minutes}]
carsonreinke commented 7 years ago

The whole .hour and .minutes would require a dependency on ActiveSupport.

Though, maybe we could just have it take a Numeric of seconds, because...

$> 1.hour.to_i
 => 3600 
$> 1.hour.is_a?(Numeric)
 => true