Reputation: 305
I am using sidekiq with sidekiq-status to check when the work is done to keep performing the action. The method I use is not much efficient but it does it.
Controller:
myjob = JobCreator.perform_async(my_param)
sleep(1)
10.times do
status = Sidekiq::Status::get myjob, :job_status
if ["OK","FAIL","NOMONEY"].include?(status)
result << status
break
end
sleep(1)
end
How can I make this on a more direct, fast and efficient way?
Upvotes: 3
Views: 5447
Reputation: 176562
The Pro version of Sidekiq has a feature called Batches that also includes the ability to configure callbacks and fetch the status of a batch.
Batches are defined as a collection of jobs, but nothing prevents you to use a job in a batch.
As far as I know, that's the only feature that currently supports callback.
Upvotes: 3