Class: HTTP::Session::PoolManager

Inherits:
Object
  • Object
show all
Includes:
MonitorMixin
Defined in:
lib/http/session/pool_manager.rb

Instance Method Summary collapse

Constructor Details

#initialize(options, session) ⇒ PoolManager

Returns a new instance of PoolManager.

Parameters:



9
10
11
12
13
14
# File 'lib/http/session/pool_manager.rb', line 9

def initialize(options, session)
  super()
  @options = options
  @session = session
  @pools = {}
end

Instance Method Details

#with(uri, &blk) ⇒ Object

Obtain a connection.



17
18
19
20
21
22
23
24
# File 'lib/http/session/pool_manager.rb', line 17

def with(uri, &blk)
  return with_new_conn(&blk) unless @options.enabled?

  origin = HTTP::URI.parse(uri).origin
  return with_new_conn(&blk) unless connection_pool_usable?(origin)

  with_reusable_conn(origin, &blk)
end