Class: HTTPX::Resolver::Resolver
- Inherits:
-
Object
- Object
- HTTPX::Resolver::Resolver
show all
- Includes:
- Callbacks, Loggable
- Defined in:
- lib/httpx/resolver/resolver.rb
Constant Summary
collapse
- RECORD_TYPES =
{
Socket::AF_INET6 => Resolv::DNS::Resource::IN::AAAA,
Socket::AF_INET => Resolv::DNS::Resource::IN::A,
}.freeze
- FAMILY_TYPES =
{
Resolv::DNS::Resource::IN::AAAA => "AAAA",
Resolv::DNS::Resource::IN::A => "A",
}.freeze
Constants included
from Loggable
Loggable::COLORS
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Loggable
#log, #log_exception
Methods included from Callbacks
#callbacks_for?, #emit, #on, #once, #only
Constructor Details
#initialize(family, options) ⇒ Resolver
Returns a new instance of Resolver.
33
34
35
36
37
|
# File 'lib/httpx/resolver/resolver.rb', line 33
def initialize(family, options)
@family = family
@record_type = RECORD_TYPES[family]
@options = Options.new(options)
end
|
Instance Attribute Details
#family ⇒ Object
Returns the value of attribute family.
29
30
31
|
# File 'lib/httpx/resolver/resolver.rb', line 29
def family
@family
end
|
#pool=(value) ⇒ Object
31
32
33
|
# File 'lib/httpx/resolver/resolver.rb', line 31
def pool=(value)
@pool = value
end
|
Class Method Details
.multi? ⇒ Boolean
24
25
26
|
# File 'lib/httpx/resolver/resolver.rb', line 24
def multi?
true
end
|
Instance Method Details
#close ⇒ Object
Also known as:
terminate
39
|
# File 'lib/httpx/resolver/resolver.rb', line 39
def close; end
|
#closed? ⇒ Boolean
43
44
45
|
# File 'lib/httpx/resolver/resolver.rb', line 43
def closed?
true
end
|
#emit_addresses(connection, family, addresses, early_resolve = false) ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/httpx/resolver/resolver.rb', line 51
def emit_addresses(connection, family, addresses, early_resolve = false)
addresses.map! do |address|
address.is_a?(IPAddr) ? address : IPAddr.new(address.to_s)
end
return if !early_resolve && connection.addresses && !addresses.intersect?(connection.addresses)
log { "resolver: answer #{FAMILY_TYPES[RECORD_TYPES[family]]} #{connection.origin.host}: #{addresses.inspect}" }
if @pool && !connection.io &&
connection.options.ip_families.size > 1 &&
family == Socket::AF_INET &&
addresses.first.to_s != connection.origin.host.to_s
log { "resolver: A response, applying resolution delay..." }
@pool.after(0.05) do
unless connection.state == :closed ||
(connection.addresses && addresses.intersect?(connection.addresses))
emit_resolved_connection(connection, addresses, early_resolve)
end
end
else
emit_resolved_connection(connection, addresses, early_resolve)
end
end
|
#empty? ⇒ Boolean
47
48
49
|
# File 'lib/httpx/resolver/resolver.rb', line 47
def empty?
true
end
|