response = Stalker.enqueue_with_response("sum", :a => 1, :b => 2)
or
Stalker.enqueue_with_response("sum", :a => 1, :b => 2) do |response|
puts "1 +2 = #{response['sum']}"
end
and the worker:
job_with_response "sum" do |args|
return :sum => args['a'] + args['b']
end
This would work by adding something like :respond_to => "stalker-response-#{$$}-#{SecureRandom.uuid}" to the job params, then subscribing to that queue (perhaps with a configurable timeout) where the worker will then enqueue it's return value once finished.
There could also be partial responses so one could do something like:
job_with_response "sum" do |args, response|
response['status'] = 'going to calculate!'
response['status_pct'] = 0
response['sum'] = args['a'] + args['b']
response['status'] = 'done calculating!'
response['status_pct'] = 100
end
I'd like to see something like :
and the worker:
This would work by adding something like :respond_to => "stalker-response-#{$$}-#{SecureRandom.uuid}" to the job params, then subscribing to that queue (perhaps with a configurable timeout) where the worker will then enqueue it's return value once finished.
There could also be partial responses so one could do something like:
Getting a little carried away here.