Class: Faraday::Adapter::Typhoeus

Inherits:
Faraday::Adapter show all
Defined in:
lib/typhoeus/adapters/faraday.rb

Overview

Adapter to use Faraday with Typhoeus.

Examples:

Use Typhoeus.

require 'faraday'
require 'typhoeus'
require 'typhoeus/adapters/faraday'

conn = Faraday.new(url: "www.example.com") do |faraday|
  faraday.adapter :typhoeus
end

response = conn.get("/")

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.setup_parallel_manager(options = {}) ⇒ Typhoeus::Hydra

Setup Hydra with provided options.

Examples:

Setup Hydra.

Faraday::Adapter::Typhoeus.setup_parallel_manager
#=> #<Typhoeus::Hydra ... >

Parameters:

  • options (Hash) (defaults to: {})

    The options hash.

Options Hash (options):

  • :max_concurrency (Integer)

    Number of max concurrent connections to create. Default is 200.

Returns:


45
46
47
# File 'lib/typhoeus/adapters/faraday.rb', line 45

def self.setup_parallel_manager(options = {})
  ::Typhoeus::Hydra.new(options)
end

Instance Method Details

#call(env) ⇒ void

This method returns an undefined value.

Hook into Faraday and perform the request with Typhoeus.

Parameters:

  • env (Hash)

    The environment.


56
57
58
59
60
# File 'lib/typhoeus/adapters/faraday.rb', line 56

def call(env)
  super
  perform_request env
  @app.call env
end