Class: Faraday::Adapter::EMSynchrony::ParallelManager
- Defined in:
- lib/faraday/adapter/em_synchrony/parallel_manager.rb
Instance Method Summary collapse
-
#add(request, method, *args, &block) ⇒ Object
Add requests to queue.
-
#run ⇒ Object
Run all requests on queue with ‘EM::Synchrony::Multi`, wrapping it in a reactor and fiber if needed.
Instance Method Details
#add(request, method, *args, &block) ⇒ Object
Add requests to queue. The ‘request` argument should be a `EM::HttpRequest` object.
8 9 10 11 12 13 14 15 |
# File 'lib/faraday/adapter/em_synchrony/parallel_manager.rb', line 8 def add(request, method, *args, &block) queue << { :request => request, :method => method, :args => args, :block => block } end |
#run ⇒ Object
Run all requests on queue with ‘EM::Synchrony::Multi`, wrapping it in a reactor and fiber if needed.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/faraday/adapter/em_synchrony/parallel_manager.rb', line 19 def run result = nil if !EM.reactor_running? EM.run { Fiber.new do result = perform EM.stop end.resume } else result = perform end result end |