Class: SidekiqBatchJob
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- SidekiqBatchJob
- Defined in:
- app/models/sidekiq_batch_job.rb
Overview
Schema Information
Table name: sidekiq_batch_jobs
id :bigint not null, primary key
args :jsonb not null
error_class :string
error_message :text
jid :string not null
status :integer default("pending"), not null
worker_class :string not null
created_at :datetime not null
updated_at :datetime not null
sidekiq_batch_id :bigint not null
Constant Summary collapse
- ERROR_MESSAGE_MAX =
4_000
Instance Method Summary collapse
-
#mark_complete! ⇒ Object
Idempotent: returns true if the row was transitioned from ‘pending` to `complete`; false if it was already terminal.
-
#mark_failed!(error) ⇒ Object
Idempotent: returns true if the row was transitioned from ‘pending` to `failed`; false if it was already terminal.
Instance Method Details
#mark_complete! ⇒ Object
Idempotent: returns true if the row was transitioned from ‘pending` to `complete`; false if it was already terminal.
30 31 32 33 34 35 |
# File 'app/models/sidekiq_batch_job.rb', line 30 def mark_complete! self.class.where(id: id, status: "pending").update_all( status: self.class.statuses.fetch("complete"), updated_at: Time.current ).positive? end |
#mark_failed!(error) ⇒ Object
Idempotent: returns true if the row was transitioned from ‘pending` to `failed`; false if it was already terminal.
39 40 41 42 43 44 45 46 |
# File 'app/models/sidekiq_batch_job.rb', line 39 def mark_failed!(error) self.class.where(id: id, status: "pending").update_all( status: self.class.statuses.fetch("failed"), error_class: error.class.name, error_message: error..to_s.truncate(ERROR_MESSAGE_MAX), updated_at: Time.current ).positive? end |