Class: FaradayPersistentExcon::ConnectionPools
- Inherits:
-
Object
- Object
- FaradayPersistentExcon::ConnectionPools
- Defined in:
- lib/faraday_persistent_excon/connection_pools.rb
Class Attribute Summary collapse
-
.__pools ⇒ Object
Returns the value of attribute __pools.
Class Method Summary collapse
Class Attribute Details
.__pools ⇒ Object
Returns the value of attribute __pools.
4 5 6 |
# File 'lib/faraday_persistent_excon/connection_pools.rb', line 4 def __pools @__pools end |
Class Method Details
.connection_pool_for(url) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/faraday_persistent_excon/connection_pools.rb', line 20 def connection_pool_for(url) config = FaradayPersistentExcon.connection_pools[url] if config self.__pools.fetch_or_store(url) do ::ConnectionPool.new(config) do ::Excon.new(url, persistent: true, thread_safe_sockets: false) end end end end |
.with_connection_for(url, &block) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/faraday_persistent_excon/connection_pools.rb', line 9 def with_connection_for(url, &block) pool = self.connection_pool_for(url) if pool pool.with(&block) else # No pool configured. Use normal connection block.call(::Excon.new(url, persistent: false)) end end |