ruby on rails - How to notify a user after background task is finished? -
i use rails activejob
, sidekiq
backend. when user come on page sidekiq
create long-term background task, how can notice user (by render partial on web page) when task completed?
rails , sidekiq work different processes. fact confused me don't understand how handle completed status using background job.
activejob
provides after_perform callback according docs work this:
class videoprocessjob < activejob::base queue_as :default after_perform |job| usermailer.notify_video_processed(job.arguments.first) end def perform(video_id) video.find(video_id).process end end
so, don't have worry integrate directly sidekiq
or other queuing backend, talk activejob
:)
Comments
Post a Comment