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
138 def initialize
139   @session = Session.new
140   @handlers = []
141 end

Public Instance methods

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