Skip to content

Commit 5f45920

Browse files
committed
Use clearer names for variable and methods when locking polled candidates
The name `lock` alone was confusing because it's the same as ActiveRecord's lock method, and `candidates` was a bit ambiguous, easy to say explicitly that the candidates are job IDs.
1 parent 4a8aa65 commit 5f45920

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

app/models/solid_queue/ready_execution.rb

+6-5
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,19 @@ def select_and_lock(queue_relation, process_id, limit)
1818
return [] if limit <= 0
1919

2020
transaction do
21-
candidates = select_candidates(queue_relation, limit)
22-
lock(candidates, process_id)
21+
job_ids = select_candidates(queue_relation, limit)
22+
lock_candidates(job_ids, process_id)
2323
end
2424
end
2525

2626
def select_candidates(queue_relation, limit)
2727
queue_relation.ordered.limit(limit).lock("FOR UPDATE SKIP LOCKED").pluck(:job_id)
2828
end
2929

30-
def lock(candidates, process_id)
31-
return [] if candidates.none?
32-
SolidQueue::ClaimedExecution.claiming(candidates, process_id) do |claimed|
30+
def lock_candidates(job_ids, process_id)
31+
return [] if job_ids.none?
32+
33+
SolidQueue::ClaimedExecution.claiming(job_ids, process_id) do |claimed|
3334
where(job_id: claimed.pluck(:job_id)).delete_all
3435
end
3536
end

0 commit comments

Comments
 (0)