brandonhilkert / sucker_punch

Sucker Punch is a Ruby asynchronous processing library using concurrent-ruby, heavily influenced by Sidekiq and girl_friday.
MIT License
2.65k stars 114 forks source link

How can controller know when the job is done? #199

Closed arefinbigfuture closed 7 years ago

arefinbigfuture commented 7 years ago

Is there any way to let controller know that the job is done? I am using a ajax loading image until my process finishes. But after using sucker_punch, the loading image goes invisible but the process keeps running in background. How can I solve this issue in sucker_punch?

Thanks

brandonhilkert commented 7 years ago

There is no job monitoring. I would capture that in the application. Something like maybe have a database field processed_at, that's nil to start and gets a timestamp when the job completes. Your loader can poll an endpoint that checks if the job is complete every couple seconds, and once complete moves on to the next step in the application.

shobhitic commented 7 years ago

If you have actioncable, you can use that as well as a callback for when the job completes. Client subscribes to a channel specific for that job, and receives data from the sucker punch worker.