Class: Puppet::HTTP::Resolver Abstract

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

Overview

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

Create a new resolver.

Parameters:



13
14
15
# File 'lib/puppet/http/resolver.rb', line 13

def initialize(client)
  @client = client
end

Instance Method Details

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

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



43
44
45
46
47
48
49
# File 'lib/puppet/http/resolver.rb', line 43

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

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

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

  • canceled_handler (Proc) (defaults to: nil)

    (nil) optional callback allowing a resolver to cancel resolution.

Raises:

  • (NotImplementedError)

    this base class is not implemented



30
31
32
# File 'lib/puppet/http/resolver.rb', line 30

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