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.



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

#poolObject (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

#freeObject



27
28
29
# File 'lib/wayfarer/networking/pool.rb', line 27

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

#withObject



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