Class: Puppet::HTTP::Resolver::SRV Private

Inherits:
Puppet::HTTP::Resolver show all
Defined in:
lib/puppet/http/resolver/srv.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.

Resolve a service using SRV

Instance Method Summary collapse

Methods inherited from Puppet::HTTP::Resolver

#check_connection?

Constructor Details

#initialize(client, domain:, dns: Resolv::DNS.new) ⇒ SRV

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.

Returns a new instance of SRV.

Parameters:

  • client (Puppet::HTTP::Client)
  • domain (String)

    srv domain

  • dns (Resolv::DNS) (defaults to: Resolv::DNS.new)

14
15
16
17
18
# File 'lib/puppet/http/resolver/srv.rb', line 14

def initialize(client, domain:, dns: Resolv::DNS.new)
  @client = client
  @srv_domain = domain
  @delegate = Puppet::Network::Resolver.new(dns)
end

Instance Method Details

#resolve(session, name, ssl_context: nil, error_handler: nil) ⇒ Puppet::HTTP::Service

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.

Walk the available srv records and return the first that successfully connects

Parameters:

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

    the service being resolved

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

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

Returns:


34
35
36
37
38
39
40
41
42
43
44
# File 'lib/puppet/http/resolver/srv.rb', line 34

def resolve(session, name, ssl_context: nil, error_handler: nil)
  # Here we pass our HTTP service name as the DNS SRV service name
  # This is fine for :ca, but note that :puppet and :file are handled
  # specially in `each_srv_record`.
  @delegate.each_srv_record(@srv_domain, name) do |server, port|
    service = Puppet::HTTP::Service.create_service(@client, session, name, server, port)
    return service if check_connection?(session, service, ssl_context: ssl_context, error_handler: error_handler)
  end

  return nil
end