Created
April 1, 2012 07:26
-
-
Save ezkl/2272636 to your computer and use it in GitHub Desktop.
Parallel Requests w/ Faraday + Typhoeus
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "faraday" | |
require 'typhoeus' | |
conn = Faraday.new(:url => 'http://httpstat.us') do |builder| | |
builder.request :url_encoded | |
builder.response :logger | |
builder.adapter :typhoeus | |
end | |
conn.in_parallel do | |
# will use Hydra's default settings: max_concurrency: 200, memoization, initial request pool size: 10 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "faraday" | |
require 'typhoeus' | |
HYDRA = Typhoeus::Hydra.new(:max_concurrency => 5) | |
HYDRA.disable_memoization | |
conn = Faraday.new(:url => "http://httpstat.us", :parallel_manager => HYDRA) do |builder| | |
builder.request :url_encoded | |
builder.adapter :typhoeus | |
end | |
conn.in_parallel do | |
# Will use user-defined Hydra settings: max_concurrency: 5, no memoization | |
end |
great! Thanks ;)
New location for faraday Parallel requests wiki: https://github.com/lostisland/faraday/wiki/Parallel-requests
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The first example will use Typhoeus::Hydra w/ default settings:
The second example shows how to override Typhoeus::Hydra defaults w/ a custom parallel_manager
See Typhoeus::Hydra