class Faraday::Adapter::EMHttp::Manager

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

def add

def add
  if running?
    perform_request { yield }
  else
    @registered_procs << Proc.new
  end
  @num_registered += 1
end

def check_finished

def check_finished
  if @num_succeeded + @errors.size == @num_registered
    EventMachine.stop
  end
end

def initialize

def initialize
  reset
end

def perform_request

def perform_request
  client = yield
  client.callback { @num_succeeded += 1; check_finished }
  client.errback { @errors << client.error; check_finished }
end

def reset

def reset
  @registered_procs = []
  @num_registered = 0
  @num_succeeded = 0
  @errors = []
  @running = false
end

def run

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

def running?() @running end

def running?() @running end