Class: HTTPX::Resolver::System
- Inherits:
-
Resolver
show all
- Extended by:
- Forwardable
- 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
- 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.
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/httpx/resolver/system.rb', line 29
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.
25
26
27
|
# File 'lib/httpx/resolver/system.rb', line 25
def state
@state
end
|
Class Method Details
.multi? ⇒ Boolean
20
21
22
|
# File 'lib/httpx/resolver/system.rb', line 20
def multi?
false
end
|
Instance Method Details
#<<(connection) ⇒ Object
94
95
96
97
|
# File 'lib/httpx/resolver/system.rb', line 94
def <<(connection)
@connections << connection
resolve
end
|
#call ⇒ Object
70
71
72
73
74
75
76
|
# File 'lib/httpx/resolver/system.rb', line 70
def call
case @state
when :open
consume
end
nil
end
|
#close ⇒ Object
58
59
60
|
# File 'lib/httpx/resolver/system.rb', line 58
def close
transition(:closed)
end
|
#closed? ⇒ Boolean
62
63
64
|
# File 'lib/httpx/resolver/system.rb', line 62
def closed?
@state == :closed
end
|
#early_resolve(connection) ⇒ Object
99
100
101
102
|
# File 'lib/httpx/resolver/system.rb', line 99
def early_resolve(connection, **)
self << connection
true
end
|
#empty? ⇒ Boolean
54
55
56
|
# File 'lib/httpx/resolver/system.rb', line 54
def empty?
true
end
|
#handle_socket_timeout(interval) ⇒ Object
104
105
106
107
108
|
# File 'lib/httpx/resolver/system.rb', line 104
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
78
79
80
81
82
|
# File 'lib/httpx/resolver/system.rb', line 78
def interests
return if @queries.empty?
:r
end
|
#multi ⇒ Object
50
51
52
|
# File 'lib/httpx/resolver/system.rb', line 50
def multi
self
end
|
#resolvers {|_self| ... } ⇒ Object
44
45
46
47
48
|
# File 'lib/httpx/resolver/system.rb', line 44
def resolvers
return enum_for(__method__) unless block_given?
yield self
end
|
#timeout ⇒ Object
84
85
86
87
88
89
90
91
92
|
# File 'lib/httpx/resolver/system.rb', line 84
def timeout
return unless @queries.empty?
_, connection = @queries.first
return unless connection
@timeouts[connection.peer.host].first
end
|
#to_io ⇒ Object
66
67
68
|
# File 'lib/httpx/resolver/system.rb', line 66
def to_io
@pipe_read.to_io
end
|