Sha256: 9a7b68b3e720d22e89242533a01d601a5ec0a787a984b5b60a5720bed181e17b

Contents?: true

Size: 420 Bytes

Versions: 4

Compression:

Stored size: 420 Bytes

Contents

# frozen_string_literal: true

class EzClient::PersistentClientRegistry
  def initialize
    self.registry = {}
  end

  def for(url, timeout:)
    cleanup_registry!
    uri = HTTP::URI.parse(url)
    registry[uri.origin] ||= EzClient::PersistentClient.new(uri.origin, timeout)
  end

  private

  attr_accessor :registry

  def cleanup_registry!
    registry.delete_if { |_origin, client| client.timed_out? }
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ezclient-1.7.1 lib/ezclient/persistent_client_registry.rb
ezclient-1.7.0 lib/ezclient/persistent_client_registry.rb
ezclient-1.6.0 lib/ezclient/persistent_client_registry.rb
ezclient-1.5.1 lib/ezclient/persistent_client_registry.rb