class HTTPX::Resolver::Resolver

  1. lib/httpx/resolver/resolver.rb
Superclass: Object

Methods

Public Class

  1. multi?
  2. new

Public Instance

  1. close
  2. closed?
  3. emit_addresses
  4. empty?
  5. family
  6. pool

Included modules

  1. Callbacks
  2. Loggable

Constants

FAMILY_TYPES = { Resolv::DNS::Resource::IN::AAAA => "AAAA", Resolv::DNS::Resource::IN::A => "A", }.freeze  
RECORD_TYPES = { Socket::AF_INET6 => Resolv::DNS::Resource::IN::AAAA, Socket::AF_INET => Resolv::DNS::Resource::IN::A, }.freeze  

Public Instance Aliases

terminate -> close

Attributes

family [R]
pool [W]

Public Class methods

multi?()
[show source]
   # File lib/httpx/resolver/resolver.rb
24 def multi?
25   true
26 end
new(family, options)
[show source]
   # File lib/httpx/resolver/resolver.rb
33 def initialize(family, options)
34   @family = family
35   @record_type = RECORD_TYPES[family]
36   @options = options
37 end

Public Instance methods

close()
[show source]
   # File lib/httpx/resolver/resolver.rb
39 def close; end
closed?()
[show source]
   # File lib/httpx/resolver/resolver.rb
43 def closed?
44   true
45 end
emit_addresses(connection, family, addresses, early_resolve = false)
[show source]
   # File lib/httpx/resolver/resolver.rb
51 def emit_addresses(connection, family, addresses, early_resolve = false)
52   addresses.map! do |address|
53     address.is_a?(IPAddr) ? address : IPAddr.new(address.to_s)
54   end
55 
56   # double emission check, but allow early resolution to work
57   return if !early_resolve && connection.addresses && !addresses.intersect?(connection.addresses)
58 
59   log { "resolver: answer #{FAMILY_TYPES[RECORD_TYPES[family]]} #{connection.origin.host}: #{addresses.inspect}" }
60   if @pool && # if triggered by early resolve, pool may not be here yet
61      !connection.io &&
62      connection.options.ip_families.size > 1 &&
63      family == Socket::AF_INET &&
64      addresses.first.to_s != connection.origin.host.to_s
65     log { "resolver: A response, applying resolution delay..." }
66     @pool.after(0.05) do
67       unless connection.state == :closed ||
68              # double emission check
69              (connection.addresses && addresses.intersect?(connection.addresses))
70         emit_resolved_connection(connection, addresses, early_resolve)
71       end
72     end
73   else
74     emit_resolved_connection(connection, addresses, early_resolve)
75   end
76 end
empty?()
[show source]
   # File lib/httpx/resolver/resolver.rb
47 def empty?
48   true
49 end