class HTTPX::Resolver::Resolver

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

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

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
35 def initialize(family, options)
36   @family = family
37   @record_type = RECORD_TYPES[family]
38   @options = options
39 
40   set_resolver_callbacks
41 end

Public Instance methods

close()
[show source]
   # File lib/httpx/resolver/resolver.rb
51 def close; end
closed?()
[show source]
   # File lib/httpx/resolver/resolver.rb
55 def closed?
56   true
57 end
each_connection(&block)
[show source]
   # File lib/httpx/resolver/resolver.rb
43 def each_connection(&block)
44   enum_for(__method__) unless block
45 
46   return unless @connections
47 
48   @connections.each(&block)
49 end
emit_addresses(connection, family, addresses, early_resolve = false)
[show source]
   # File lib/httpx/resolver/resolver.rb
67 def emit_addresses(connection, family, addresses, early_resolve = false)
68   addresses.map! do |address|
69     address.is_a?(IPAddr) ? address : IPAddr.new(address.to_s)
70   end
71 
72   # double emission check, but allow early resolution to work
73   return if !early_resolve && connection.addresses && !addresses.intersect?(connection.addresses)
74 
75   log do
76     "resolver #{FAMILY_TYPES[RECORD_TYPES[family]]}: " \
77       "answer #{FAMILY_TYPES[RECORD_TYPES[family]]} #{connection.peer.host}: #{addresses.inspect}"
78   end
79 
80   if @current_selector && # if triggered by early resolve, session may not be here yet
81      !connection.io &&
82      connection.options.ip_families.size > 1 &&
83      family == Socket::AF_INET &&
84      addresses.first.to_s != connection.peer.host.to_s
85     log { "resolver #{FAMILY_TYPES[RECORD_TYPES[family]]}: applying resolution delay..." }
86 
87     @current_selector.after(0.05) do
88       # double emission check
89       unless connection.addresses && addresses.intersect?(connection.addresses)
90         emit_resolved_connection(connection, addresses, early_resolve)
91       end
92     end
93   else
94     emit_resolved_connection(connection, addresses, early_resolve)
95   end
96 end
empty?()
[show source]
   # File lib/httpx/resolver/resolver.rb
59 def empty?
60   true
61 end
inflight?()
[show source]
   # File lib/httpx/resolver/resolver.rb
63 def inflight?
64   false
65 end