Topic: Using delayed_job to query a long running external API

Hello there.

We've got a rails 2.3.11 site that has been asked to communicate with a very flakey xml API.  I've used httparty and it's been going OK for a year or so.

Recently the people who look after the flakey API have upgraded their systems and now it's awful.

What happens is the service is ok after a restart, that they schedule each night, and then gradually degrades over the day, the response times getting longer and longer until the call fails completely.  This causes the web site to slow down and eventually crash.

My idea is to hand off the call to delayed_job so the rest of the page loads, and once the delayed_job process has completed it will display the returned value in the page.

The bit I can't get my head around is what will show in the space where the value should be whilst the job completes?

I'd like to show something that would be meaningful, but I'm not sure how to do that.

If anyone's got any tips on this process, or other ideas, I'd love to hear from them.

I'd be happy to share my code.

V

Re: Using delayed_job to query a long running external API

Aesthetically, I like the traditional animated gif spinner, like this:

http://www.mrspeaker.net/images/spinna/spinner11.gif

I don't know what httparty is,  but if it has :loading and :success callbacks,  you could hide/show the gif using them?

Joe got a job, on the day shift, at the Utility Muffin Research Kitchen, arrogantly twisting the sterile canvas snout of a fully charged icing anointment utensil.