class Typhoeus::Hydra

execution.
@note Callbacks are going to delay the request
hydra.run
requests.each{ |request| hydra.queue(request) }
requests = (0..9).map{ Typhoeus::Request.new(“www.example.com”) }
hydra = Typhoeus::Hydra.new
@example Use the hydra to do multiple requests.
conflict with libcurls internal concurrency mechanism.
whatever technique you want to your code. That should not
from the developer and you are free to apply
it is important to know that this is completely hidden
Regarding the asynchronous behavior of the hydra,
the Hydra constructor.
can raise or lower the concurrency limit through
and start the requests as others are finished. You
that are queued up, hydra will save them for later
The built in limit is 200. When more requests than
try to make too many requests at the same time.
make in parallel. Things will get flakey if you
Hydra will also handle how many requests you can
the requests by yourself.
The benefits are that you don’t have to worry running
is achieved by using libcurls multi interface:
Hydra manages making parallel HTTP requests. This

def hydra

Returns:
  • (Typhoeus::Hydra) - A new hydra.

Other tags:
    Example: Get a hydra. -
def hydra
  Thread.current[:typhoeus_hydra] ||= new
end

def initialize(options = {})

Other tags:
    See: http://rubydoc.info/github/typhoeus/ethon/Ethon/Multi#initialize-instance_method -

Options Hash: (**options)
  • :max_concurrency (Integer) -- Number

Parameters:
  • options (Hash) -- The options hash.

Other tags:
    Example: Create a hydra with max_concurrency. -
    Example: Create a hydra. -
def initialize(options = {})
  @options = options
  @max_concurrency = @options.fetch(:max_concurrency, 200)
  @multi = Ethon::Multi.new(options.reject{|k,_| k==:max_concurrency})
end