Class: Wayfarer::Networking::Pool
- Inherits:
-
Object
- Object
- Wayfarer::Networking::Pool
- Includes:
- Singleton
- Defined in:
- lib/wayfarer/networking/pool.rb
Instance Attribute Summary collapse
-
#pool ⇒ Object
readonly
Returns the value of attribute pool.
Instance Method Summary collapse
- #free ⇒ Object
-
#initialize ⇒ Pool
constructor
A new instance of Pool.
- #with ⇒ Object
Constructor Details
#initialize ⇒ Pool
Returns a new instance of Pool.
15 16 17 18 19 |
# File 'lib/wayfarer/networking/pool.rb', line 15 def initialize @pool = ConnectionPool.new(**Wayfarer.config.dig(:network, :pool), &method(:context)) at_exit { free } end |
Instance Attribute Details
#pool ⇒ Object (readonly)
Returns the value of attribute pool.
13 14 15 |
# File 'lib/wayfarer/networking/pool.rb', line 13 def pool @pool end |
Instance Method Details
#free ⇒ Object
27 28 29 |
# File 'lib/wayfarer/networking/pool.rb', line 27 def free self.class.finalizer.call(@pool) end |
#with ⇒ Object
21 22 23 24 25 |
# File 'lib/wayfarer/networking/pool.rb', line 21 def with(&) @pool.with(&) rescue ConnectionPool::TimeoutError => e raise Wayfarer::UserAgentTimeoutError, e end |