Function call when sidebyq-superworker superbyte is completed

I have setup two working Sidekiqs in a Rails 4.2 application, where the first one performs several tasks and the other sends an email when all these tasks are completed. The two are connected in this superoperator:

Superworker.define(:PrioritySuperworker, :object_class, :object_id, :priority_ids) do batch priority_ids: :priority_id do PriorityMailsWorker :object_class, :object_id, :priority_id end SendConfirmationWorker :object_class, :object_id end 

I would like to perform another operation in a model in which this superoperator is called, but only if the superjob has been completed (which means that all the subtasks in it have also been completed). I saw that Sidekiq Pro can launch a callback after the package is complete, but I cannot afford to use it since I work on an open source platform. Can this be done with Superworker or any other free tool?

+5
source share
1 answer

I don't know if this is an option, but if I'm not mistaken, it looks pretty much what you need.

According to sidekiq-sperworker gem docs , you can simply set up a third worker and add it to the superoperator, so make sure that it only works when all the previous ones are complete.

In your example, it will look like this:

 Superworker.define(:PrioritySuperworker, :object_class, :object_id, :priority_ids) do batch priority_ids: :priority_id do PriorityMailsWorker :object_class, :object_id, :priority_id end SendConfirmationWorker :object_class, :object_id PerformAnotherOperationInModel :object_class, :object_id end 
+2
source

All Articles