Class: HTTPX::Resolver::System
- Inherits:
-
Object
- Object
- HTTPX::Resolver::System
show all
- Includes:
- ResolverMixin
- Defined in:
- lib/httpx/resolver/system.rb
Constant Summary
collapse
- RESOLV_ERRORS =
[Resolv::ResolvError,
Resolv::DNS::Requester::RequestError,
Resolv::DNS::EncodeError,
Resolv::DNS::DecodeError].freeze
ResolverMixin::CHECK_IF_IP
Constants included
from Loggable
Loggable::COLORS
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Loggable
#log, #log_exception
Methods included from Callbacks
#emit, #on, #once, #only
Constructor Details
#initialize(options) ⇒ System
Returns a new instance of System.
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/httpx/resolver/system.rb', line 17
def initialize(options)
@options = Options.new(options)
@resolver_options = @options.resolver_options
@state = :idle
resolv_options = @resolver_options.dup
timeouts = resolv_options.delete(:timeouts)
resolv_options.delete(:cache)
@resolver = Resolv::DNS.new(resolv_options.empty? ? nil : resolv_options)
@resolver.timeouts = timeouts || Resolver::RESOLVE_TIMEOUT
end
|
Instance Attribute Details
#state ⇒ Object
Returns the value of attribute state.
15
16
17
|
# File 'lib/httpx/resolver/system.rb', line 15
def state
@state
end
|
Instance Method Details
#<<(connection) ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/httpx/resolver/system.rb', line 36
def <<(connection)
hostname = connection.origin.host
addresses = connection.addresses ||
ip_resolve(hostname) ||
system_resolve(hostname) ||
@resolver.getaddresses(hostname)
throw(:resolve_error, resolve_error(hostname)) if addresses.empty?
emit_addresses(connection, addresses)
rescue Errno::EHOSTUNREACH, *RESOLV_ERRORS => e
emit_resolve_error(connection, hostname, e)
end
|
#closed? ⇒ Boolean
28
29
30
|
# File 'lib/httpx/resolver/system.rb', line 28
def closed?
true
end
|
#empty? ⇒ Boolean
32
33
34
|
# File 'lib/httpx/resolver/system.rb', line 32
def empty?
true
end
|
#uncache ⇒ Object
49
|
# File 'lib/httpx/resolver/system.rb', line 49
def uncache(*); end
|