-
-
Save eladmeidar/4175225 to your computer and use it in GitHub Desktop.
Parallel Requests w/ Faraday + Typhoeus
This file contains hidden or 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 hidden or 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment