Class: Faraday::Adapter::EMSynchrony

### Home Classes Methods

### In Files

- lib/faraday/adapter/em_synchrony.rb
- lib/faraday/adapter/em_synchrony/parallel_manager.rb

### Parent

Faraday::Adapter

### Namespace

- CLASS Faraday::Adapter::EMSynchrony::ParallelManager

### Methods

- ::setup_parallel_manager
- #call

### Included Modules

- Faraday::Adapter::EMHttp::Options

### Class/Module Index

Quicksearch

- Faraday
- Faraday::Adapter
- Faraday::Adapter::EMHttp
- Faraday::Adapter::EMHttp::Manager
- Faraday::Adapter::EMHttp::Options
- Faraday::Adapter::EMSynchrony
- Faraday::Adapter::EMSynchrony::ParallelManager
- Faraday::Adapter::Excon
- Faraday::Adapter::HTTPClient
- Faraday::Adapter::NetHttp
- Faraday::Adapter::NetHttpPersistent
- Faraday::Adapter::Parallelism
- Faraday::Adapter::Patron
- Faraday::Adapter::Rack
- Faraday::Adapter::Test
- Faraday::Adapter::Test::Stub
- Faraday::Adapter::Test::Stubs
- Faraday::Adapter::Test::Stubs::NotFound
- Faraday::Adapter::Typhoeus
- Faraday::AutoloadHelper
- Faraday::ClientError
- Faraday::CompositeReadIO
- Faraday::Connection
- Faraday::ConnectionFailed
- Faraday::ConnectionOptions
- Faraday::Env
- Faraday::Error
- Faraday::FlatParamsEncoder
- Faraday::Middleware
- Faraday::MiddlewareRegistry
- Faraday::MissingDependency
- Faraday::NestedParamsEncoder
- Faraday::Options
- Faraday::ParsingError
- Faraday::ProxyOptions
- Faraday::RackBuilder
- Faraday::RackBuilder::Handler
- Faraday::RackBuilder::StackLocked
- Faraday::Request
- Faraday::Request::Authorization
- Faraday::Request::BasicAuthentication
- Faraday::Request::Instrumentation
- Faraday::Request::Instrumentation::Options
- Faraday::Request::Multipart
- Faraday::Request::Retry
- Faraday::Request::Retry::Options
- Faraday::Request::TokenAuthentication
- Faraday::Request::UrlEncoded
- Faraday::RequestOptions
- Faraday::ResourceNotFound
- Faraday::Response
- Faraday::Response::Logger
- Faraday::Response::Middleware
- Faraday::Response::RaiseError
- Faraday::SSLError
- Faraday::SSLOptions
- Faraday::TimeoutError
- Faraday::Utils
- Faraday::Utils::Headers
- Faraday::Utils::ParamsHash
- EmHttpSslPatch
- Object

No matching classes.

# Faraday::Adapter::EMSynchrony

### Public Class Methods

setup_parallel_manager(options = {}) click to toggle source

    # File lib/faraday/adapter/em_synchrony.rb, line 16
    def self.setup_parallel_manager(options = {})
      ParallelManager.new
    end

### Public Instance Methods

call(env) click to toggle source

    # File lib/faraday/adapter/em_synchrony.rb, line 20
    def call(env)
      super
      request = EventMachine::HttpRequest.new(Utils::URI(env[:url].to_s), connection_config(env))

      http_method = env[:method].to_s.downcase.to_sym

      # Queue requests for parallel execution.
      if env[:parallel_manager]
        env[:parallel_manager].add(request, http_method, request_config(env)) do |resp|
          save_response(env, resp.response_header.status, resp.response) do |resp_headers|
            resp.response_header.each do |name, value|
              resp_headers[name.to_sym] = value
            end
          end

          # Finalize the response object with values from `env`.
          env[:response].finish(env)
        end

      # Execute single request.
      else
        client = nil
        block = lambda { request.send(http_method, request_config(env)) }

        if !EM.reactor_running?
          EM.run do
            Fiber.new {
              client = block.call
              EM.stop
            }.resume
          end
        else
          client = block.call
        end

        raise client.error if client.error

        save_response(env, client.response_header.status, client.response) do |resp_headers|
          client.response_header.each do |name, value|
            resp_headers[name.to_sym] = value
          end
        end
      end

      @app.call env
    rescue Errno::ECONNREFUSED
      raise Error::ConnectionFailed, $!
    rescue EventMachine::Connectify::CONNECTError => err
      if err.message.include?("Proxy Authentication Required")
        raise Error::ConnectionFailed, %{407 "Proxy Authentication Required "}
      else
        raise Error::ConnectionFailed, err
      end
    rescue => err
      if defined?(OpenSSL) && OpenSSL::SSL::SSLError === err
        raise Faraday::SSLError, err
      else
        raise
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.