Class: Gem::Request::ConnectionPools

Inherits:
Object
  • Object
show all
Defined in:
lib/rubygems/request/connection_pools.rb

Overview

:nodoc:

Class Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(proxy_uri, cert_files) ⇒ ConnectionPools

Returns a new instance of ConnectionPools.



13
14
15
16
17
18
# File 'lib/rubygems/request/connection_pools.rb', line 13

def initialize(proxy_uri, cert_files)
  @proxy_uri  = proxy_uri
  @cert_files = cert_files
  @pools      = {}
  @pool_mutex = Mutex.new
end

Class Attribute Details

.clientObject

Returns the value of attribute client



9
10
11
# File 'lib/rubygems/request/connection_pools.rb', line 9

def client
  @client
end

Instance Method Details

#close_allObject



33
34
35
# File 'lib/rubygems/request/connection_pools.rb', line 33

def close_all
  @pools.each_value {|pool| pool.close_all}
end

#pool_for(uri) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rubygems/request/connection_pools.rb', line 20

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)
      else
        Gem::Request::HTTPPool.new(http_args, @cert_files, @proxy_uri)
      end
  end
end