Sha256: 32147dcd46d14cd5335fa8cb4680565c474f28a31daee1279aec78e863c28f62

Contents?: true

Size: 932 Bytes

Versions: 1

Compression:

Stored size: 932 Bytes

Contents

# frozen_string_literal: true

module Wayfarer
  module Networking
    class Pool
      include Singleton
      extend Forwardable

      cattr_accessor :registry, default: { http: HTTP,
                                           ferrum: Ferrum,
                                           selenium: Selenium,
                                           capybara: Capybara }

      attr_reader :pool

      def initialize
        @pool = ConnectionPool.new(size: Wayfarer.config.network.pool_size,
                                   timeout: Wayfarer.config.network.pool_timeout,
                                   &method(:context))
      end

      delegate with: :pool

      def free
        pool.shutdown(&:renew)
      end

    private

      def context
        Wayfarer::Networking::Context.new(strategy)
      end

      def strategy
        self.class.registry[Wayfarer.config.network.agent].new
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wayfarer-0.4.1 lib/wayfarer/networking/pool.rb