Class: HTTPX::Resolver::System

Inherits:
Object
  • Object
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

Constants included from ResolverMixin

ResolverMixin::CHECK_IF_IP

Constants included from Loggable

Loggable::COLORS

Instance Method Summary collapse

Methods included from Loggable

#log

Methods included from Callbacks

#emit, #on, #once

Constructor Details

#initialize(_, options) ⇒ System

Returns a new instance of System.



15
16
17
18
19
20
21
# File 'lib/httpx/resolver/system.rb', line 15

def initialize(_, options)
  @options = Options.new(options)
  roptions = @options.resolver_options
  @state = :idle
  @resolver = Resolv::DNS.new(roptions.nil? ? nil : roptions)
  @resolver.timeouts = roptions[:timeouts] if roptions
end

Instance Method Details

#<<(channel) ⇒ Object



31
32
33
34
35
36
37
38
# File 'lib/httpx/resolver/system.rb', line 31

def <<(channel)
  hostname = channel.uri.host
  addresses = ip_resolve(hostname) || system_resolve(hostname) || @resolver.getaddresses(hostname)
  return emit_resolve_error(channel, hostname) if addresses.empty?
  emit_addresses(channel, addresses)
rescue Errno::EHOSTUNREACH, *RESOLV_ERRORS => e
  emit_resolve_error(channel, hostname, e)
end

#closed?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/httpx/resolver/system.rb', line 23

def closed?
  true
end

#empty?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/httpx/resolver/system.rb', line 27

def empty?
  true
end

#uncacheObject



40
# File 'lib/httpx/resolver/system.rb', line 40

def uncache(*); end