class Faraday::Adapter::HTTPX::ParallelManager

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

Methods

Public Class

  1. new

Public Instance

  1. enqueue
  2. run

Included modules

  1. RequestMixin

Public Class methods

new ()
[show source]
    # File lib/httpx/adapters/faraday.rb
134 def initialize
135   @session = Session.new
136   @handlers = []
137 end

Public Instance methods

enqueue (request)
[show source]
    # File lib/httpx/adapters/faraday.rb
139 def enqueue(request)
140   handler = ResponseHandler.new(request)
141   @handlers << handler
142   handler
143 end
run ()
[show source]
    # File lib/httpx/adapters/faraday.rb
145 def run
146   requests = @handlers.map { |handler| build_request(handler.env) }
147   env = @handlers.last.env
148 
149   proxy_options = { uri: env.request.proxy }
150 
151   session = @session.with(options_from_env(env))
152   session = session.plugin(:proxy).with_proxy(proxy_options) if env.request.proxy
153 
154   responses = session.request(requests)
155   Array(responses).each_with_index do |response, index|
156     handler = @handlers[index]
157     handler.on_response.call(response)
158     handler.on_complete.call(handler.env)
159   end
160 end