Answer the question
In order to leave comments, you need to log in
Callback after executing a group of sidekiq tasks?
Good afternoon!
Periodically runs a rake task and runs sidekiq background tasks with different parameters.
Feed.find_each do |feed| #может быть 1000 элементов
FeedUpdate.perform_async(feed.id)
end
batch = Sidekiq::Batch.new
batch.description = "Batch description (this is optional)"
batch.on(:success, MyCallback)
batch.jobs do
rows.each { |row| RowWorker.perform_async(row) }
end
worker_ids = []
Feed.find_each do |feed|
worker_ids.push(FeedUpdate.perform_async(feed.id))
end
loop do
sleep(0.5)
in_progress = false
worker_ids.each do |id|
status = Sidekiq::Status::status(id)
if (status == :queued) || (status == :working)
in_progress = true
end
end
break if in_progress == false
end
Callback.run
Answer the question
In order to leave comments, you need to log in
Look, there is such a microscope: https://github.com/socialpandas/sidekiq-superworker
You can hammer nails with them - paint a task queue, and at the end set a task that pulls the desired callback.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question