Skip to content

Commit 893b23f

Browse files
committed
Refactor a bit how next batch of scheduled executions is selected
For clarity.
1 parent 42e33d4 commit 893b23f

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

app/models/solid_queue/scheduled_execution.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ class SolidQueue::ScheduledExecution < SolidQueue::Execution
88
class << self
99
def prepare_next_batch(batch_size)
1010
transaction do
11-
prepared_job_ids = prepare_batch next_batch(batch_size).lock("FOR UPDATE SKIP LOCKED").tap(&:load)
12-
prepared_job_ids.present?
11+
batch = next_batch(batch_size).lock("FOR UPDATE SKIP LOCKED").tap(&:load)
12+
prepare_batch batch
1313
end
1414
end
1515

lib/solid_queue/scheduler.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ def initialize(**options)
1919

2020
private
2121
def run
22-
with_polling_volume do
23-
unless select_and_prepare_next_batch
24-
procline "waiting"
25-
interruptible_sleep(polling_interval)
26-
end
22+
batch = prepare_next_batch
23+
24+
unless batch.size > 0
25+
procline "waiting"
26+
interruptible_sleep(polling_interval)
2727
end
2828
end
2929

30-
def select_and_prepare_next_batch
30+
def prepare_next_batch
3131
with_polling_volume do
3232
SolidQueue::ScheduledExecution.prepare_next_batch(batch_size)
3333
end

0 commit comments

Comments
 (0)