Class: Gem::Request::ConnectionPools
- Inherits:
-
Object
- Object
- Gem::Request::ConnectionPools
- Defined in:
- lib/rubygems/request/connection_pools.rb
Overview
:nodoc:
Class Attribute Summary collapse
-
.client ⇒ Object
Returns the value of attribute client.
Instance Method Summary collapse
- #close_all ⇒ Object
-
#initialize(proxy_uri, cert_files, pool_size = 1) ⇒ ConnectionPools
constructor
A new instance of ConnectionPools.
- #pool_for(uri) ⇒ Object
Constructor Details
#initialize(proxy_uri, cert_files, pool_size = 1) ⇒ ConnectionPools
Returns a new instance of ConnectionPools.
10 11 12 13 14 15 16 |
# File 'lib/rubygems/request/connection_pools.rb', line 10 def initialize(proxy_uri, cert_files, pool_size = 1) @proxy_uri = proxy_uri @cert_files = cert_files @pools = {} @pool_mutex = Thread::Mutex.new @pool_size = pool_size end |
Class Attribute Details
.client ⇒ Object
Returns the value of attribute client.
7 8 9 |
# File 'lib/rubygems/request/connection_pools.rb', line 7 def client @client end |
Instance Method Details
#close_all ⇒ Object
31 32 33 |
# File 'lib/rubygems/request/connection_pools.rb', line 31 def close_all @pools.each_value(&:close_all) end |
#pool_for(uri) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rubygems/request/connection_pools.rb', line 18 def pool_for(uri) http_args = net_http_args(uri, @proxy_uri) key = http_args + [https?(uri)] @pool_mutex.synchronize do @pools[key] ||= if https? uri Gem::Request::HTTPSPool.new(http_args, @cert_files, @proxy_uri, @pool_size) else Gem::Request::HTTPPool.new(http_args, @cert_files, @proxy_uri, @pool_size) end end end |