Object
EventMachine based Multi request client, based on a streaming HTTPRequest class, which allows you to open multiple parallel connections and return only when all of them finish. (i.e. ideal for parallelizing workloads)
EventMachine.run { multi = EventMachine::MultiRequest.new # add multiple requests to the multi-handler multi.add(:a, EventMachine::HttpRequest.new('http://www.google.com/').get) multi.add(:b, EventMachine::HttpRequest.new('http://www.yahoo.com/').get) multi.callback { p multi.responses[:callback] p multi.responses[:errback] EventMachine.stop } }
# File lib/em-http/multi.rb, line 36 def add(name, conn) raise 'Duplicate Multi key' if @requests.key? name @requests[name] = conn conn.callback { @responses[:callback][name] = conn; check_progress } conn.errback { @responses[:errback][name] = conn; check_progress } end
Generated with the Darkfish Rdoc Generator 2.