Module: Rmega::ConnPool
Defined Under Namespace
Classes: ConnectionManager
Class Method Summary collapse
- .connection_manager ⇒ Object
-
.get(url, options = {}) ⇒ Object
url: URI / String options: any options that Net::HTTP.new accepts.
Methods included from Options
Methods included from Loggable
Class Method Details
.connection_manager ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rmega/conn_pool.rb', line 14 def self.connection_manager synchronize do @connection_managers ||= [] # we first clear all old ones removed = @connection_managers.reject!(&:stale?) (removed || []).each(&:close_connections!) # get the manager Thread.current[:http_connection_manager] ||= self.synchronize do manager = ConnectionManager.new @connection_managers << manager manager end end end |
.get(url, options = {}) ⇒ Object
url: URI / String options: any options that Net::HTTP.new accepts
9 10 11 12 |
# File 'lib/rmega/conn_pool.rb', line 9 def self.get(url, = {}) uri = url.is_a?(URI) ? url : URI(url) connection_manager.get_client(uri, ) end |