class Faraday::Adapter::HTTPX::ParallelManager

  1. lib/httpx/adapters/faraday.rb
Superclass: Object

Methods

Public Class

  1. new

Public Instance

  1. connection
  2. enqueue
  3. run

Included modules

  1. RequestMixin

Public Class methods

new(options)
[show source]
    # File lib/httpx/adapters/faraday.rb
189 def initialize(options)
190   @handlers = []
191   @connection_options = options
192 end

Public Instance methods

connection(env)

from Faraday::Adapter#connection

[show source]
    # File lib/httpx/adapters/faraday.rb
226 def connection(env)
227   conn = build_connection(env)
228   return conn unless block_given?
229 
230   yield conn
231 end
enqueue(request)
[show source]
    # File lib/httpx/adapters/faraday.rb
194 def enqueue(request)
195   handler = ResponseHandler.new(request)
196   @handlers << handler
197   handler
198 end
run()
[show source]
    # File lib/httpx/adapters/faraday.rb
200 def run
201   return unless @handlers.last
202 
203   env = @handlers.last.env
204 
205   connect(env) do |session|
206     requests = @handlers.map { |handler| session.build_request(*build_request(handler.env)) }
207 
208     if env.request.stream_response?
209       requests.each do |request|
210         request.response_on_data = env.request.on_data
211       end
212     end
213 
214     responses = session.request(*requests)
215     Array(responses).each_with_index do |response, index|
216       handler = @handlers[index]
217       handler.on_response.call(response)
218       handler.on_complete.call(handler.env) if handler.on_complete
219     end
220   end
221 rescue ::HTTPX::TimeoutError => e
222   raise Faraday::TimeoutError, e
223 end