Module: ActiveJob::BatchId
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/active_job/batch_id.rb
Instance Method Summary collapse
- #batch ⇒ Object
- #deserialize(job_data) ⇒ Object
- #enqueue(options = {}) ⇒ Object
-
#initialize(*arguments, **kwargs) ⇒ Object
Seed membership at construction for enqueue paths deferred until after the batch context ends, notably bulk enqueue.
- #serialize ⇒ Object
Instance Method Details
#batch ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/active_job/batch_id.rb', line 42 def batch batch_id_to_load = callback_batch_id || batch_id return if batch_id_to_load.nil? return @batch if defined?(@batch) && @loaded_batch_id == batch_id_to_load @loaded_batch_id = batch_id_to_load @batch = SolidQueue::Batch.find_by(id: batch_id_to_load) end |
#deserialize(job_data) ⇒ Object
36 37 38 39 40 |
# File 'lib/active_job/batch_id.rb', line 36 def deserialize(job_data) super self.batch_id = job_data["batch_id"] self.callback_batch_id = job_data["callback_batch_id"] end |
#enqueue(options = {}) ⇒ Object
24 25 26 27 |
# File 'lib/active_job/batch_id.rb', line 24 def enqueue( = {}) self.batch_id = SolidQueue::Batch.current_batch_id || batch_id if solid_queue_job? super end |
#initialize(*arguments, **kwargs) ⇒ Object
Seed membership at construction for enqueue paths deferred until after the batch context ends, notably bulk enqueue. Enqueueing inside another batch rebinds membership; enqueueing without a batch preserves it. SolidQueue::Job.enqueue_all repeats this capture because bulk enqueue bypasses #enqueue.
19 20 21 22 |
# File 'lib/active_job/batch_id.rb', line 19 def initialize(*arguments, **kwargs) super self.batch_id = SolidQueue::Batch.current_batch_id if solid_queue_job? end |
#serialize ⇒ Object
29 30 31 32 33 34 |
# File 'lib/active_job/batch_id.rb', line 29 def serialize super.tap do |data| data["batch_id"] = batch_id if batch_id data["callback_batch_id"] = callback_batch_id if callback_batch_id end end |