Class: HTTPX::Resolver::System
Constant Summary
collapse
- RESOLV_ERRORS =
[Resolv::ResolvError,
Resolv::DNS::Requester::RequestError,
Resolv::DNS::EncodeError,
Resolv::DNS::DecodeError].freeze
- DONE =
1
- ERROR =
2
Constants inherited
from Resolver
Resolver::FAMILY_TYPES, Resolver::RECORD_TYPES
Constants included
from Loggable
Loggable::COLORS, Loggable::USE_DEBUG_LOG
Instance Attribute Summary collapse
Attributes inherited from Resolver
#current_selector, #current_session, #family, #options
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Resolver
#each_connection, #emit_addresses, #inflight?
Methods included from Loggable
#log, #log_exception
Methods included from Callbacks
#callbacks_for?, #emit, #on, #once
Constructor Details
#initialize(options) ⇒ System
Returns a new instance of System.
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/httpx/resolver/system.rb', line 25
def initialize(options)
super(nil, options)
@resolver_options = @options.resolver_options
resolv_options = @resolver_options.dup
timeouts = resolv_options.delete(:timeouts) || Resolver::RESOLVE_TIMEOUT
@_timeouts = Array(timeouts)
@timeouts = Hash.new { |tims, host| tims[host] = @_timeouts.dup }
resolv_options.delete(:cache)
@connections = []
@queries = []
@ips = []
@pipe_mutex = Thread::Mutex.new
@state = :idle
end
|
Instance Attribute Details
#state ⇒ Object
Returns the value of attribute state.
23
24
25
|
# File 'lib/httpx/resolver/system.rb', line 23
def state
@state
end
|
Class Method Details
.multi? ⇒ Boolean
18
19
20
|
# File 'lib/httpx/resolver/system.rb', line 18
def multi?
false
end
|
Instance Method Details
#<<(connection) ⇒ Object
90
91
92
93
|
# File 'lib/httpx/resolver/system.rb', line 90
def <<(connection)
@connections << connection
resolve
end
|
#call ⇒ Object
66
67
68
69
70
71
72
|
# File 'lib/httpx/resolver/system.rb', line 66
def call
case @state
when :open
consume
end
nil
end
|
#close ⇒ Object
54
55
56
|
# File 'lib/httpx/resolver/system.rb', line 54
def close
transition(:closed)
end
|
#closed? ⇒ Boolean
58
59
60
|
# File 'lib/httpx/resolver/system.rb', line 58
def closed?
@state == :closed
end
|
#early_resolve(connection) ⇒ Object
95
96
97
98
|
# File 'lib/httpx/resolver/system.rb', line 95
def early_resolve(connection, **)
self << connection
true
end
|
#empty? ⇒ Boolean
50
51
52
|
# File 'lib/httpx/resolver/system.rb', line 50
def empty?
true
end
|
#handle_socket_timeout(interval) ⇒ Object
100
101
102
103
104
|
# File 'lib/httpx/resolver/system.rb', line 100
def handle_socket_timeout(interval)
error = HTTPX::ResolveTimeoutError.new(interval, "timed out while waiting on select")
error.set_backtrace(caller)
on_error(error)
end
|
#interests ⇒ Object
74
75
76
77
78
|
# File 'lib/httpx/resolver/system.rb', line 74
def interests
return if @queries.empty?
:r
end
|
#multi ⇒ Object
46
47
48
|
# File 'lib/httpx/resolver/system.rb', line 46
def multi
self
end
|
#resolvers {|_self| ... } ⇒ Object
40
41
42
43
44
|
# File 'lib/httpx/resolver/system.rb', line 40
def resolvers
return enum_for(__method__) unless block_given?
yield self
end
|
#timeout ⇒ Object
80
81
82
83
84
85
86
87
88
|
# File 'lib/httpx/resolver/system.rb', line 80
def timeout
return unless @queries.empty?
_, connection = @queries.first
return unless connection
@timeouts[connection.peer.host].first
end
|
#to_io ⇒ Object
62
63
64
|
# File 'lib/httpx/resolver/system.rb', line 62
def to_io
@pipe_read.to_io
end
|