Methods
Public Class
Public Instance
Constants
DEFAULTS | = | { nameserver: nil, **Resolv::DNS::Config.default_config_hash, packet_size: 512, timeouts: Resolver::RESOLVE_TIMEOUT, }.freeze | ||
DNS_PORT | = | 53 |
Attributes
state | [R] |
Public Class methods
new(family, options)
[show source]
# File lib/httpx/resolver/native.rb 24 def initialize(family, options) 25 super 26 @ns_index = 0 27 @resolver_options = DEFAULTS.merge(@options.resolver_options) 28 @socket_type = @resolver_options.fetch(:socket_type, :udp) 29 @nameserver = if (nameserver = @resolver_options[:nameserver]) 30 nameserver = nameserver[family] if nameserver.is_a?(Hash) 31 Array(nameserver) 32 end 33 @ndots = @resolver_options.fetch(:ndots, 1) 34 @search = Array(@resolver_options[:search]).map { |srch| srch.scan(/[^.]+/) } 35 @_timeouts = Array(@resolver_options[:timeouts]) 36 @timeouts = Hash.new { |timeouts, host| timeouts[host] = @_timeouts.dup } 37 @connections = [] 38 @name = nil 39 @queries = {} 40 @read_buffer = "".b 41 @write_buffer = Buffer.new(@resolver_options[:packet_size]) 42 @state = :idle 43 end
Public Instance methods
<<(connection)
[show source]
# File lib/httpx/resolver/native.rb 80 def <<(connection) 81 if @nameserver.nil? 82 ex = ResolveError.new("No available nameserver") 83 ex.set_backtrace(caller) 84 connection.force_reset 85 throw(:resolve_error, ex) 86 else 87 @connections << connection 88 resolve 89 end 90 end
call()
[show source]
# File lib/httpx/resolver/native.rb 61 def call 62 case @state 63 when :open 64 consume 65 end 66 end
close()
[show source]
# File lib/httpx/resolver/native.rb 45 def close 46 transition(:closed) 47 end
closed?()
[show source]
# File lib/httpx/resolver/native.rb 53 def closed? 54 @state == :closed 55 end
handle_socket_timeout(interval)
[show source]
# File lib/httpx/resolver/native.rb 100 def handle_socket_timeout(interval); end
interests()
[show source]
# File lib/httpx/resolver/native.rb 68 def interests 69 case @state 70 when :idle 71 transition(:open) 72 when :closed 73 transition(:idle) 74 transition(:open) 75 end 76 77 calculate_interests 78 end
terminate()
[show source]
# File lib/httpx/resolver/native.rb 49 def terminate 50 emit(:close, self) 51 end
timeout()
[show source]
# File lib/httpx/resolver/native.rb 92 def timeout 93 return if @connections.empty? 94 95 @start_timeout = Utils.now 96 hosts = @queries.keys 97 @timeouts.values_at(*hosts).reject(&:empty?).map(&:first).min 98 end