开发者

Polling, web sockets, or comet on a rails app

I'm trying to determine the best way to go about doing something for a project I have where I rely on an external API/service which takes ~2.5-4 seconds for a reply.

Currently I'm using javascript to load the api/data after the DOM has loaded then jquery updates a partial on the page. Pretty as the loader I have is, it still locks up the server process, so I'd like to move it out into a Heroku worker using delayed_job or something else? And the info from the API is user specific and not something that could be in a cron job.

The data I'm pulling onl开发者_StackOverflow中文版y needs to be updated every few hours and is recorded locally in the DB, so I'm guessing an all out web socket such as that provided by Pusherapp.com would be overkill?

I'm leaning towards polling using delayed_job and waiting for a status update to determine it's completeness. Has anyone done this with delayed_job? Hints or caveats?

Thanks


Yeah you can definitely do something like that with delayed_job... but ultimately it sounds like you need something cron-like for scheduling, right? Alternatively, can't you use cron on heroku to just run a rake task every couple of hours?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜