Sha256: 0a1d73d9736619072107fb734d01d10185546e37c0bcaf56c033a5a8ccbad91b

Contents?: true

Size: 1.61 KB

Versions: 148

Compression:

Stored size: 1.61 KB

Contents

# Resolver base class. Each resolver represents a different strategy for
# resolving a service name into a list of candidate servers and ports.
#
# @abstract Subclass and override {#resolve} to create a new resolver.
# @api public
class Puppet::HTTP::Resolver
  #
  # Create a new resolver.
  #
  # @param [Puppet::HTTP::Client] client
  def initialize(client)
    @client = client
  end

  # Return a working server/port for the resolver. This is the base
  # implementation and is meant to be a placeholder.
  #
  # @param [Puppet::HTTP::Session] session
  # @param [Symbol] name the service to resolve
  # @param [Puppet::SSL::SSLContext] ssl_context (nil) optional ssl context to
  #   use when creating a connection
  # @param [Proc] canceled_handler (nil) optional callback allowing a resolver
  #   to cancel resolution.
  #
  # @raise [NotImplementedError] this base class is not implemented
  #
  # @api public
  def resolve(session, name, ssl_context: nil, canceled_handler: nil)
    raise NotImplementedError
  end

  # Check a given connection to establish if it can be relied on for future use.
  #
  # @param [Puppet::HTTP::Session] session
  # @param [Puppet::HTTP::Service] service
  # @param [Puppet::SSL::SSLContext] ssl_context
  #
  # @return [Boolean] Returns true if a connection is successful, false otherwise
  #
  # @api public
  def check_connection?(session, service, ssl_context: nil)
    service.connect(ssl_context: ssl_context)
    return true
  rescue Puppet::HTTP::ConnectionError => e
    Puppet.log_exception(e, "Connection to #{service.url} failed, trying next route: #{e.message}")
    return false
  end
end

Version data entries

148 entries across 148 versions & 1 rubygems

Version Path
puppet-7.20.0 lib/puppet/http/resolver.rb
puppet-7.20.0-x86-mingw32 lib/puppet/http/resolver.rb
puppet-7.20.0-x64-mingw32 lib/puppet/http/resolver.rb
puppet-7.20.0-universal-darwin lib/puppet/http/resolver.rb
puppet-7.19.0 lib/puppet/http/resolver.rb
puppet-7.19.0-x86-mingw32 lib/puppet/http/resolver.rb
puppet-7.19.0-x64-mingw32 lib/puppet/http/resolver.rb
puppet-7.19.0-universal-darwin lib/puppet/http/resolver.rb
puppet-7.18.0 lib/puppet/http/resolver.rb
puppet-7.18.0-x86-mingw32 lib/puppet/http/resolver.rb
puppet-7.18.0-x64-mingw32 lib/puppet/http/resolver.rb
puppet-7.18.0-universal-darwin lib/puppet/http/resolver.rb
puppet-7.17.0 lib/puppet/http/resolver.rb
puppet-7.17.0-x86-mingw32 lib/puppet/http/resolver.rb
puppet-7.17.0-x64-mingw32 lib/puppet/http/resolver.rb
puppet-7.17.0-universal-darwin lib/puppet/http/resolver.rb
puppet-7.16.0 lib/puppet/http/resolver.rb
puppet-7.16.0-x86-mingw32 lib/puppet/http/resolver.rb
puppet-7.16.0-x64-mingw32 lib/puppet/http/resolver.rb
puppet-7.16.0-universal-darwin lib/puppet/http/resolver.rb