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
31 32 33 34 35 36 |
# File 'lib/roqua/scheduling/scheduler.rb', line 31 def advisory_lock_name db_name = ActiveRecord::Base.respond_to?(:connection_db_config) \ ? ActiveRecord::Base.connection_db_config.database : ActiveRecord::Base.connection_config[:database] "#{db_name}_cron_lock" end |
#jobs_to_run ⇒ Object
19 20 21 |
# File 'lib/roqua/scheduling/scheduler.rb', line 19 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 16 17 |
# 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 Appsignal.increment_counter("scheduler.completed", 1) end end |
#schedule ⇒ Object
27 28 29 |
# File 'lib/roqua/scheduling/scheduler.rb', line 27 def schedule Roqua::Scheduling::Schedule.current_schedule end |
#tasks ⇒ Object
23 24 25 |
# File 'lib/roqua/scheduling/scheduler.rb', line 23 def tasks schedule.tasks end |