Class: SolidQueue::ClaimedExecution
Defined Under Namespace
Classes: Result
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Execution
create_all_from_jobs, execution_data_from_jobs, type, #type
Methods inherited from Record
non_blocking_lock
Class Method Details
.claiming(job_ids, process_id, &block) ⇒ Object
15
16
17
18
19
20
21
22
|
# File 'app/models/solid_queue/claimed_execution.rb', line 15
def claiming(job_ids, process_id, &block)
job_data = Array(job_ids).collect { |job_id| { job_id: job_id, process_id: process_id } }
insert_all!(job_data)
where(job_id: job_ids, process_id: process_id).load.tap do |claimed|
block.call(claimed)
end
end
|
.discard_all_from_jobs ⇒ Object
37
38
39
|
# File 'app/models/solid_queue/claimed_execution.rb', line 37
def discard_all_from_jobs(*)
raise UndiscardableError, "Can't discard jobs in progress"
end
|
.discard_all_in_batches ⇒ Object
33
34
35
|
# File 'app/models/solid_queue/claimed_execution.rb', line 33
def discard_all_in_batches(*)
raise UndiscardableError, "Can't discard jobs in progress"
end
|
.release_all ⇒ Object
24
25
26
27
28
29
30
31
|
# File 'app/models/solid_queue/claimed_execution.rb', line 24
def release_all
SolidQueue.instrument(:release_many_claimed) do |payload|
includes(:job).tap do |executions|
payload[:size] = executions.size
executions.each(&:release)
end
end
end
|
Instance Method Details
#discard ⇒ Object
63
64
65
|
# File 'app/models/solid_queue/claimed_execution.rb', line 63
def discard
raise UndiscardableError, "Can't discard a job in progress"
end
|
42
43
44
45
46
47
48
49
50
51
52
|
# File 'app/models/solid_queue/claimed_execution.rb', line 42
def perform
result = execute
if result.success?
finished
else
failed_with(result.error)
end
ensure
job.unblock_next_blocked_job
end
|
#release ⇒ Object
54
55
56
57
58
59
60
61
|
# File 'app/models/solid_queue/claimed_execution.rb', line 54
def release
SolidQueue.instrument(:release_claimed, job_id: job.id, process_id: process_id) do
transaction do
job.dispatch_bypassing_concurrency_limits
destroy!
end
end
end
|