ruby on rails - How can I retrieve data onscreen from an external API without tying up a request? -
i have rails 3 application lets user perform search against 3rd party database via api. potentially bring quite bit of xml data. also, api busy serving requests other users , have nontrivial delay in response time.
i run 2 webservers can't afford have delayed request obviously. use sidekiq
process long-running jobs, in cases i've needed haven't had return value screen.
i use pusher
communicate user when background job finished. checking out, don't know if can used kind of data want push screen. right pops dialog boxes messages send it.
i have thought of pretty kooky stuff, running request via sidekiq, sending results session object or file, using pusher kick off kind of event grab data , populate screen it. seems kind of rube goldberg-ish.
i appreciate or insight can offer problem!
i had similar situation not long ago , way i've fixed using memcache , threads.
i've thought using sidekiq, sidekiq ideal if don't expect use data right away, memcache , threads worked pretty , gave amount of control.
instead of calling api directly assign api request thread , thread once done write memcache, in case can happen incrementally, same api being able return more data same endpoint until complete.
from ui have basic ajax pooling mechanism hit controller , check memcache data , status see if complete or not, sign ui need keep pooling more data.
Comments
Post a Comment