Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/models/solid_queue/execution/dispatching.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module Dispatching
def dispatch_jobs(job_ids)
jobs = Job.where(id: job_ids)

# Dispatcher Lifecycle - 7 - Dispatches jobs and then deletes from executions
Job.dispatch_all(jobs).map(&:id).then do |dispatched_job_ids|
where(id: where(job_id: dispatched_job_ids).pluck(:id)).delete_all
end
Expand Down
1 change: 1 addition & 0 deletions app/models/solid_queue/job/executable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def prepare_all_for_execution(jobs)
end

def dispatch_all(jobs)
# Dispatcher Lifecycle - 8 - Dispatches jobs with and without concurrency limits
with_concurrency_limits, without_concurrency_limits = jobs.partition(&:concurrency_limited?)

dispatch_all_at_once(without_concurrency_limits)
Expand Down
1 change: 1 addition & 0 deletions app/models/solid_queue/scheduled_execution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class ScheduledExecution < Execution
class << self
def dispatch_next_batch(batch_size)
transaction do
# Dispatcher Lifecycle - 6 - Finds the next available jobs and dispatches them
job_ids = next_batch(batch_size).non_blocking_lock.pluck(:job_id)
if job_ids.empty? then 0
else
Expand Down
2 changes: 2 additions & 0 deletions lib/solid_queue/dispatcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ def metadata
attr_reader :concurrency_maintenance

def poll
# Dispatcher Lifecycle - 4 - Dispatching next batch
batch = dispatch_next_batch

batch.zero? ? polling_interval : 0.seconds
end

def dispatch_next_batch
with_polling_volume do
# Dispatcher Lifecycle - 5 - Dispatching next batch
ScheduledExecution.dispatch_next_batch(batch_size)
end
end
Expand Down
2 changes: 2 additions & 0 deletions lib/solid_queue/processes/poller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def metadata

private
def run
# Dispatcher Lifecycle - 2 - Polling loop started
start_loop
end

Expand All @@ -26,6 +27,7 @@ def start_loop
break if shutting_down?

delay = wrap_in_app_executor do
# Dispatcher Lifecycle - 3 - Polling loop
poll
end

Expand Down
1 change: 1 addition & 0 deletions lib/solid_queue/processes/runnable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module Runnable
attr_writer :mode

def start
# Dispatcher Lifecycle - 1 - Dispatcher started
boot

if running_async?
Expand Down