Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to perform a Sidekiq callback when a group of workers are complete

Lets say I have a Sidekiq task that processes products to my database. Each product is grouped by store, so an overly simplified example of my code would be something like this...

stores.each do |store|
  store.products.each do |product|
    ProductWorker.perform_async(product.id)
  end
end

When all the products from one store have run. I'd like to update the stores last_updated column with the current time. But only when the last task for that store has run. How can I achieve this?

like image 643
tob88 Avatar asked Aug 08 '14 14:08

tob88


1 Answers

You can try sidekiq-batch gem to solve your problem. It's like paid Batches feature of Sidekiq Pro and has same api.

like image 119
vctr Avatar answered Nov 15 '22 10:11

vctr