Class: OnlineMigrations::BackgroundMigrations::MigrationJob
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- OnlineMigrations::BackgroundMigrations::MigrationJob
- Defined in:
- lib/online_migrations/background_migrations/migration_job.rb
Constant Summary collapse
- STATUSES =
[ :enqueued, :running, :failed, :succeeded, :cancelled, ]
Instance Method Summary collapse
-
#retry ⇒ Object
Mark this job as ready to be processed again.
-
#stuck? ⇒ Boolean
Whether the job is considered stuck (is running for some configured time).
Instance Method Details
#retry ⇒ Object
Mark this job as ready to be processed again.
This is used when retrying failed jobs.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/online_migrations/background_migrations/migration_job.rb', line 72 def retry if failed? transaction do update!( status: self.class.statuses[:enqueued], attempts: 0, started_at: nil, finished_at: nil, error_class: nil, error_message: nil, backtrace: nil ) migration.enqueued! if migration.failed? end true else false end end |
#stuck? ⇒ Boolean
Whether the job is considered stuck (is running for some configured time).
63 64 65 66 |
# File 'lib/online_migrations/background_migrations/migration_job.rb', line 63 def stuck? timeout = OnlineMigrations.config.background_migrations.stuck_jobs_timeout running? && updated_at <= timeout.seconds.ago end |