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.



10
11
12
13
14
15
# File 'lib/rubygems/request/connection_pools.rb', line 10

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.



7
8
9
# File 'lib/rubygems/request/connection_pools.rb', line 7

def client
  @client
end

Instance Method Details

#close_allObject



30
31
32
# File 'lib/rubygems/request/connection_pools.rb', line 30

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

#pool_for(uri) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/rubygems/request/connection_pools.rb', line 17

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