Class: SolidQueue::ScheduledExecution

Inherits:
Execution show all
Includes:
Dispatching
Defined in:
lib/solid_queue_mongoid/models/classes.rb,
lib/solid_queue_mongoid/models/scheduled_execution.rb

Constant Summary

Constants inherited from Record

Record::INDEX_HINTS

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Execution

create_all_from_jobs, #discard, discard_all_from_jobs, discard_all_in_batches, type, #type

Methods inherited from Record

create_or_find_by!, find_by!, index, index_specifications, index_specifications=, inherited, non_blocking_lock, supports_insert_conflict_target?, transaction, use_index

Class Method Details

.dispatch_next_batch(batch_size) ⇒ Object Also known as: dispatch_due_batch



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/solid_queue_mongoid/models/scheduled_execution.rb', line 18

def dispatch_next_batch(batch_size)
  Mongoid.transaction do
    SolidQueue.instrument(:dispatch_scheduled, batch_size: batch_size) do |payload|
      job_ids = next_batch(batch_size).pluck(:job_id)
      payload[:size] = if job_ids.empty?
                         0
                       else
                         dispatch_jobs(job_ids)
                       end
      payload[:size]
    end
  end
end

Instance Method Details

#dispatch ⇒ Object

Instance method: dispatch this single execution if the job is due now. Mirrors the AR behaviour used in tests.



37
38
39
40
41
# File 'lib/solid_queue_mongoid/models/scheduled_execution.rb', line 37

def dispatch
  return unless job.due?

  self.class.dispatch_jobs([job_id])
end