Class: OctaSpace::Transport::PersistentTransport
- Inherits:
-
FaradayTransport
- Object
- Base
- FaradayTransport
- OctaSpace::Transport::PersistentTransport
- Defined in:
- lib/octaspace/transport/persistent_transport.rb
Overview
Keep-alive HTTP transport using persistent connections and a connection pool
Requires optional gems:
gem "faraday-net_http_persistent"
gem "connection_pool"
Inherits all retry/failover/hook logic from FaradayTransport. Overrides adapter configuration to use net_http_persistent with pooling.
Constant Summary
Constants inherited from FaradayTransport
FaradayTransport::RETRY_METHODS, FaradayTransport::RETRY_STATUSES
Instance Method Summary collapse
-
#initialize(config) ⇒ PersistentTransport
constructor
A new instance of PersistentTransport.
-
#pool_stats ⇒ Hash
Connection pool diagnostics per URL.
-
#shutdown ⇒ Object
Shut down all connection pools gracefully.
Methods inherited from FaradayTransport
#delete, #get, #patch, #post, #put
Methods inherited from Base
#delete, #get, #patch, #post, #put
Constructor Details
#initialize(config) ⇒ PersistentTransport
Returns a new instance of PersistentTransport.
21 22 23 24 25 |
# File 'lib/octaspace/transport/persistent_transport.rb', line 21 def initialize(config) @pools = {} @pools_mutex = Mutex.new super end |
Instance Method Details
#pool_stats ⇒ Hash
Returns connection pool diagnostics per URL.
28 29 30 31 32 33 34 |
# File 'lib/octaspace/transport/persistent_transport.rb', line 28 def pool_stats @pools_mutex.synchronize do @pools.transform_values do |pool| {size: pool.size, available: pool.available} end end end |
#shutdown ⇒ Object
Shut down all connection pools gracefully
37 38 39 40 41 42 |
# File 'lib/octaspace/transport/persistent_transport.rb', line 37 def shutdown @pools_mutex.synchronize do @pools.each_value { |pool| pool.shutdown { |_conn| nil } } @pools.clear end end |