Skip to content

Instantly share code, notes, and snippets.

@deepfryed
Created August 13, 2010 03:41
Show Gist options
  • Save deepfryed/522229 to your computer and use it in GitHub Desktop.
Save deepfryed/522229 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
require 'gems/environment'
require 'em-jack'
require 'em-http'
EM.run do
jack = EMJack::Connection.new
jack.use('stalk') do
5.times {|n| jack.put "hello #{n+1}" }
end
jack.watch('stalk') do
jack.each_job do |job|
p 'received %d' % job.jobid
http = EM::HttpRequest.new('http://www.google.com/').get
http.callback do
p 'http callback'
job.delete { p "deleted" }
end
http.errback do
p 'http errback'
job.delete { p "deleted" }
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment