I'm considering using Gearman for our asynchronous infrastructure
needs, however, I'm looking for a particular piece of functionality
that I haven't found in the docs: waiting on a task from another
process. Essentially, I want to kick off an asynchronous task during
one HTTP request (in process A), and then at some point in the future
wait for its completion during another HTTP request (in process B).
It looks like both the Ruby and Perl interfaces only expose waiting on
a taskset object you (the process) create. Is this correct?
Is there some way to get a global key to a taskset and use it to wait
for its completion in a process from which it didn't originate?
Thanks!
We do this in Digg's submission process. What we do is set a key in
Memcached that gets set when you run the initial background job in
process A (say the key is 'crawl.098707097809708970987098709', which
is a unique key for the URL being submitted). We then flip over to an
intermediary page that looks like those pages when you search
Travelocity that says "We're digging through your results ..." that,
via an AJAX endpoint pings that Memcached key periodically. If the key
is empty we wait. If it's not we move to the next page.
There is no mechanism in Gearman itself for this. Once an asynchronous
background job is completed it disappears completely from the queue
and, since nothing is waiting on the other end for the results,
there's nothing you can do about that. As a result Memcache works
great as an intermediary.
Hope that helps.
--Joe