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
187 def initialize(options)
188   @handlers = []
189   @connection_options = options
190 end

Public Instance methods

connection(env)

from Faraday::Adapter#connection

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