I have successfully used Sidekiq to run background jobs triggered by user actions in a Rails 3.2 application. My specific application includes sending and receiving data from and from an external source through a third-party API.
I need to synchronize data with this external source, constantly checking for each user if there is data available for download.
All my background jobs are still user initiated, as I mentioned above. My question is: if I want to constantly check for external data for each user in a while , I suppose:
# pseudocode while true for user in User.active data = user.get_data next if data.blank? UserDataWorker.perform_async(user.id) end end
then where should I put the code above? I am confused about how to generate a continuous task. I do not want to put the code in a Sidekiq employee, because it will be just a job that never ends. Or should I do this?
I donβt want to put it in the rake task, because then how can I control this rake task? Everything I read about Sidekiq seems to indicate a Worker performing a task that is finite and can be completed or erroneous. I appreciate any help you can offer.
source share