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

Inherits:
Puppet::HTTP::Resolver show all
Defined in:
lib/puppet/http/resolver/srv.rb

Overview

Resolve a service using DNS SRV records.

Instance Method Summary collapse

Methods inherited from Puppet::HTTP::Resolver

#check_connection?

Constructor Details

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

Create an DNS SRV resolver.

Parameters:

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

    srv domain

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


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

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

Instance Method Details

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

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)
  • canceled_handler (Proc) (defaults to: nil)

    optional callback allowing a resolver to cancel resolution.

Returns:



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/puppet/http/resolver/srv.rb', line 31

def resolve(session, name, ssl_context: nil, canceled_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)
  end

  nil
end