Class: Wayfarer::Networking::Pool

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/wayfarer/networking/pool.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePool

Returns a new instance of Pool.



23
24
25
26
27
# File 'lib/wayfarer/networking/pool.rb', line 23

def initialize
  @pool = ConnectionPool.new(**Wayfarer.config.dig(:network, :pool), &method(:context))

  at_exit { free }
end

Instance Attribute Details

#poolObject (readonly)

Returns the value of attribute pool.



21
22
23
# File 'lib/wayfarer/networking/pool.rb', line 21

def pool
  @pool
end

Instance Method Details

#freeObject



35
36
37
# File 'lib/wayfarer/networking/pool.rb', line 35

def free
  self.class.finalizer.call(@pool)
end

#withObject



29
30
31
32
33
# File 'lib/wayfarer/networking/pool.rb', line 29

def with(&)
  @pool.with(&)
rescue ConnectionPool::TimeoutError => e
  raise Wayfarer::UserAgentTimeoutError, e
end