Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to monitor for completion of a Sidekiq job?

I'm using a Sidekiq worker to complete some requests to Facebook after a user signs-in for the first time. Typically the task takes around 20 seconds or so.

I'd like to load some information on to the page using an ajax request as soon as the sync is completed, but am unsure as to the best way to check for the job completion with Javascript.

One possibility would be to configure the Sidekiq worker to set a cookie after the rest of the jobs are done. Then I can use a setTimeout function to keep checking for the cookie before calling the load function. But I'm unsure whether this is the best way to be doing this. Could I be using Redis instead?

like image 392
Paul Avatar asked May 04 '13 04:05

Paul


People also ask

What is a sidekiq process?

Sidekiq is a framework for background job processing that is very useful for handling expensive computation, emails, and other processes that is better served outside of the main web application.

How do I test my sidekiq workers?

To test your Sidekiq Worker jobs array, run WorkerNameHere.jobs in terminal and see if it contains your job with your jid. If it does, then it was enqueued in Sidekiq to be run as a job.


1 Answers

Paul, initially you have to take a look on this PubSub on Rails tutorial!

This will be your better solution for notify user when asynchronous things occur/complete in the backend.

tip: If you're using heroku, you'll have a lot of libraries with abstract this complexity for you.

like image 73
Neilor Caldeira Avatar answered Oct 21 '22 08:10

Neilor Caldeira