Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

calling multiple sidekiq workers from a worker

I have to run multiple jobs upon a request from the user. However only one is important among those.

So i have a MainWorker in whose perform method I call different other workers like Worker1, Worker2.

Worker1 and Worker2 can be delayed, I need to give priority to MainWorker.

so here is how my perform method looks now

class MainWorker
 def perform( user_id ) 
   User.find( user_id ).main_task
   Worker1.perform_async( user_id ) 
   Worker2.perform_async( user_id ) 
 end
end

I might have more sub workers coming up later. I want to know if this is a good practice or there is a much better way to do this. I however give custom queue names and priority to those based on the worker.

like image 483
aBadAssCowboy Avatar asked Nov 02 '22 12:11

aBadAssCowboy


1 Answers

There are some 3rd party add-ons for Sidekiq. See here: https://github.com/mperham/sidekiq/wiki/Related-Projects

One that might be helpful for you is: SidekiqSuperworker.

like image 183
chaserx Avatar answered Nov 09 '22 04:11

chaserx