I have a setup of two Sidekiq workers in my Rails 4.2 app where the first one performs several jobs and the other one sends en email when all those jobs have been completed. These two are coupled in this superworker:
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 the model where this superworker is called, but only if the superjob has been completed (which means all the subjobs in it were also completed). I've seen that Sidekiq Pro can fire a callback on completion of a batch but I can't afford using it since I work on an open source platform. Is there any way this could be done using Superworker or any other free tool?
I do not know if it is an option, but if I am not mistaken, it looks pretty much as what you need.
According to sidekiq-sperworker gem docs, you could just set up the third worker and add it to superworker, thus making sure it only runs when all previous are completed.
With your example it'll look as follows:
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With