Class: OnlineMigrations::BackgroundMigrations::Scheduler
- Inherits:
-
Object
- Object
- OnlineMigrations::BackgroundMigrations::Scheduler
- Defined in:
- lib/online_migrations/background_migrations/scheduler.rb
Overview
Class responsible for scheduling background migrations. It selects runnable background migrations and runs them one step (one batch) at a time. A migration is considered runnable if it is not completed and the time interval between
successive runs has passed.
Scheduler should be configured to run periodically, for example, via cron.
Class Method Summary collapse
Instance Method Summary collapse
-
#run ⇒ Object
Runs Scheduler.
Class Method Details
.run ⇒ Object
18 19 20 |
# File 'lib/online_migrations/background_migrations/scheduler.rb', line 18 def self.run new.run end |
Instance Method Details
#run ⇒ Object
Runs Scheduler
23 24 25 26 27 28 29 30 |
# File 'lib/online_migrations/background_migrations/scheduler.rb', line 23 def run active_migrations = Migration.runnable.active.queue_order runnable_migrations = active_migrations.select(&:interval_elapsed?) runnable_migrations.each do |migration| run_migration_job(migration) end end |