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:


11
12
13
# File 'lib/puppet/http/resolver.rb', line 11

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


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

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

#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


28
29
30
# File 'lib/puppet/http/resolver.rb', line 28

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