Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blocking job queuing with response #19

Open
kke opened this issue Aug 14, 2012 · 1 comment
Open

Blocking job queuing with response #19

kke opened this issue Aug 14, 2012 · 1 comment

Comments

@kke
Copy link

kke commented Aug 14, 2012

I'd like to see something like :

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

Getting a little carried away here.

@kke
Copy link
Author

kke commented Aug 14, 2012

I made a pull request to han repo that provides this. han#12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant