sidekiq: push background results to front

60 views
Skip to first unread message

Soichi Ishida

unread,
Jun 2, 2013, 11:17:25 PM6/2/13
to rubyonra...@googlegroups.com
Rails 3.2.11
Sidekiq latest

My app continues background jobs that generate texts as the output.

class ProcessText
include Sidekiq::Worker

def perform(name, count)
puts "executing..."
@feed = Feed.first
@feed.process # here it returns String results!
end
end


What I want is basically how to send (or push?) the result texts to a
particular web page.

The above function 'perform' is in app/workers directory, as instructed
in the documentation of Sidekiq. It must be simple but I am unable to
find the way to do it yet.
Somehow I need to let a controller reload the page, OR with the help of
jquery ajax, to show the results, I guess?

Could anyone give me tips?

soichi

--
Posted via http://www.ruby-forum.com/.

Walter Lee Davis

unread,
Jun 3, 2013, 9:41:58 AM6/3/13
to rubyonra...@googlegroups.com
Rails 4 will let you stream the update to the page, but in Rails < 4, you want to have the page poll for changes. Use Prototype's Ajax.PeriodicalUpdater or whatever the jQuery equivalent is. Prototype's can be configured to throttle back the frequency of requests after a period of same-results answers, and of course you can remove the behavior once the update has been delivered.

Walter

>
> soichi
>
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/903eeb9bf373921c0cade5ca14980eac%40ruby-forum.com?hl=en-US.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Reply all
Reply to author
Forward
0 new messages