Class: SolidQueue::RecurringExecution

Inherits:
Execution
  • Object
show all
Defined in:
app/models/solid_queue/recurring_execution.rb

Defined Under Namespace

Classes: AlreadyRecorded

Class Method Summary collapse

Methods inherited from Execution

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

Methods inherited from Record

non_blocking_lock

Class Method Details

.clear_in_batches(batch_size: 500) ⇒ Object



22
23
24
25
26
27
# File 'app/models/solid_queue/recurring_execution.rb', line 22

def clear_in_batches(batch_size: 500)
  loop do
    records_deleted = clearable.limit(batch_size).delete_all
    break if records_deleted == 0
  end
end

.record(task_key, run_at, &block) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'app/models/solid_queue/recurring_execution.rb', line 10

def record(task_key, run_at, &block)
  transaction do
    block.call.tap do |active_job|
      if active_job
        create!(job_id: active_job.provider_job_id, task_key: task_key, run_at: run_at)
      end
    end
  end
rescue ActiveRecord::RecordNotUnique => e
  raise AlreadyRecorded
end