Class: Faraday::Adapter::EMHttp::Manager

### Home Classes Methods

### In Files

- lib/faraday/adapter/em_http.rb

### Parent

Object

### Methods

- ::new
- #add
- #check_finished
- #perform_request
- #reset
- #run
- #running?

### 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::EMHttp::Manager

The parallel manager is designed to start an EventMachine loop and block until all registered requests have been completed.

### Public Class Methods

new() click to toggle source

    # File lib/faraday/adapter/em_http.rb, line 176
    def initialize
      reset
    end

### Public Instance Methods

add() click to toggle source

    # File lib/faraday/adapter/em_http.rb, line 190
    def add
      if running?
        perform_request { yield }
      else
        @registered_procs << Proc.new
      end
      @num_registered += 1
    end

check_finished() click to toggle source

    # File lib/faraday/adapter/em_http.rb, line 221
    def check_finished
      if @num_succeeded + @errors.size == @num_registered
        EventMachine.stop
      end
    end

perform_request() click to toggle source

    # File lib/faraday/adapter/em_http.rb, line 215
    def perform_request
      client = yield
      client.callback { @num_succeeded += 1; check_finished }
      client.errback { @errors << client.error; check_finished }
    end

reset() click to toggle source

    # File lib/faraday/adapter/em_http.rb, line 180
    def reset
      @registered_procs = []
      @num_registered = 0
      @num_succeeded = 0
      @errors = []
      @running = false
    end

run() click to toggle source

    # File lib/faraday/adapter/em_http.rb, line 199
    def run
      if @num_registered > 0
        @running = true
        EventMachine.run do
          @registered_procs.each do |proc|
            perform_request(&proc)
          end
        end
        if @errors.size > 0
          raise Faraday::Error::ClientError, @errors.first || "connection failed"
        end
      end
    ensure
      reset
    end

running?() click to toggle source

    # File lib/faraday/adapter/em_http.rb, line 188
    def running?() @running end

[Validate]

Generated with the Darkfish Rdoc Generator 2.