Class: Roqua::Scheduling::Scheduler
- Inherits:
-
Object
- Object
- Roqua::Scheduling::Scheduler
- Defined in:
- lib/roqua/scheduling/scheduler.rb
Instance Method Summary collapse
- #advisory_lock_name ⇒ Object
- #jobs_to_run ⇒ Object
- #ping ⇒ Object
- #schedule ⇒ Object
- #tasks ⇒ Object
Instance Method Details
#advisory_lock_name ⇒ Object
29 30 31 |
# File 'lib/roqua/scheduling/scheduler.rb', line 29 def advisory_lock_name "#{ActiveRecord::Base.connection_config[:database]}_cron_lock" end |
#jobs_to_run ⇒ Object
17 18 19 |
# File 'lib/roqua/scheduling/scheduler.rb', line 17 def jobs_to_run Roqua::Scheduling::CronJob.where('next_run_at <= ?', Time.now) end |
#ping ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/roqua/scheduling/scheduler.rb', line 4 def ping with_advisory_lock do jobs_to_run.each do |cron_job| begin run_task cron_job rescue Exception => ex Roqua::Support::Errors.report(ex) raise ex if Rails.env.test? end end end end |
#schedule ⇒ Object
25 26 27 |
# File 'lib/roqua/scheduling/scheduler.rb', line 25 def schedule Roqua::Scheduling::Schedule.current_schedule end |
#tasks ⇒ Object
21 22 23 |
# File 'lib/roqua/scheduling/scheduler.rb', line 21 def tasks schedule.tasks end |