EM::MultiRequest.newAPI1.new.execute()API2.new.execute()API3.new.execute()multi.callback do#process all API responses hereendend
Celluloid?
require 'goliath'require 'em-synchrony/em-http'class GetLengthinclude EM::Deferrableattr_accessor :datadef execute(url)req = EM::HttpRequest.new(url).agetreq.callback do@data = req.response.length.to_ssucceed()endreq.errback { fail }selfendendclass Hello < Goliath::APIdef response(env)multi = EventMachine::Synchrony::Multi.newmulti.add :google, GetLength.new.execute('http://www.google.ie/')multi.add :yahoo, GetLength.new.execute('http://www.yahoo.com/')response = multi.perform.responses[:callback][200, {}, {:google => response[:google].data,:yahoo => response[:yahoo].data}]endend