Class: Puppet::HTTP::Resolver Abstract Private

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/http/resolver.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

This class is abstract.

Subclass and override #resolve to create a new resolver.

Resolver base class. Each resolver represents a different strategy for resolving a service name into a list of candidate servers and ports.

Direct Known Subclasses

SRV, ServerList, Settings

Defined Under Namespace

Classes: SRV, ServerList, Settings

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Resolver

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Create a new resolver

Parameters:



17
18
19
# File 'lib/puppet/http/resolver.rb', line 17

def initialize(client)
  @client = client
end

Instance Method Details

#check_connection?(session, service, ssl_context: nil, error_handler: nil) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Check a given connection to establish if it can be relied on for future use

Parameters:

Returns:

  • (Boolean)

    Returns true if a connection is successful, false otherwise



53
54
55
56
57
58
59
60
# File 'lib/puppet/http/resolver.rb', line 53

def check_connection?(session, service, ssl_context: nil, error_handler: nil)
  service.connect(ssl_context: ssl_context)
  return true
rescue Puppet::HTTP::ConnectionError => e
  error_handler.call(e) if error_handler
  Puppet.debug("Connection to #{service.url} failed, trying next route: #{e.message}")
  return false
end

#resolve(session, name, ssl_context: nil, error_handler: nil) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return a working server/port for the resolver. This is the base implementation and is meant to be a placeholder.

Parameters:

  • session (Puppet::HTTP::Session)
  • name (Symbol)

    the service to resolve

  • ssl_context (Puppet::SSL::SSLContext) (defaults to: nil)

    (nil) optional ssl context to use when creating a connection

  • error_handler (Proc) (defaults to: nil)

    (nil) optional callback for each error encountered while resolving a route.

Raises:

  • (NotImplementedError)

    this base class is not implemented



36
37
38
# File 'lib/puppet/http/resolver.rb', line 36

def resolve(session, name, ssl_context: nil, error_handler: nil)
  raise NotImplementedError
end