Does em-synchrony support asynchronous call on oracle database?

14 views
Skip to first unread message

Gwowen Fu

unread,
Sep 21, 2015, 11:09:49 AM9/21/15
to Ruby on Rails: Talk
Hi,

I want to make two asynchronous calls on a Ruby on Rails server. One HTTP request and one database query. After both calls are finished then I will merge them to become one single JSON object.

After spending many hours on the internet, the closest thing I could find is em-synchrony. Just like EventMachine and Fiber, no oracle database support is mentioned anywhere.

Is it doable?

If that's not the right approach, how could it be done? Should I create a new Thread for one of the request then join them?

require 'eventmachine'
require 'em-synchrony'
require 'em-synchrony/em-http'

EM.synchrony do

  multi = EventMachine::Synchrony::Multi.new
  multi.add :page1, EventMachine::HttpRequest.new("http://google.com/search?q=eventmachine").aget
  multi.add :page2, { return "5" }

  data = multi.perform.responses[:callback].values

  EM::Synchrony::Iterator.new(data, 2).each do |page, iter|

  end

  puts "All done! Stopping event loop."
  EventMachine.stop
end


  
Reply all
Reply to author
Forward
0 new messages