Module: Typhoeus::Hydra::EasyPool Private

Included in:
Typhoeus, Typhoeus::Hydra
Defined in:
lib/typhoeus/hydra/easy_pool.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

The easy pool stores already initialized easy handles for future use. This is useful because creating them is quite expensive.

Since:

  • 0.5.0

Instance Method Summary collapse

Instance Method Details

#easy_poolArray<Ethon::Easy>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return the easy pool.

Examples:

Return easy pool.

hydra.easy_pool

Returns:

  • (Array<Ethon::Easy>)

    The easy pool.

Since:

  • 0.5.0



17
18
19
# File 'lib/typhoeus/hydra/easy_pool.rb', line 17

def easy_pool
  @easy_pool ||= []
end

#get_easyEthon::Easy

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return an easy from pool.

Examples:

Return easy.

hydra.get_easy

Returns:

  • (Ethon::Easy)

    The easy.

Since:

  • 0.5.0



37
38
39
# File 'lib/typhoeus/hydra/easy_pool.rb', line 37

def get_easy
  easy_pool.pop || Ethon::Easy.new
end

#release_easy(easy) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Releases easy into pool. The easy handle is resetted before it gets back in.

Examples:

Release easy.

hydra.release_easy(easy)

Since:

  • 0.5.0



26
27
28
29
# File 'lib/typhoeus/hydra/easy_pool.rb', line 26

def release_easy(easy)
  easy.reset
  easy_pool << easy
end