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
Instance Attribute Summary collapse
Attributes inherited from Resolver
#family, #pool
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Resolver
#emit_addresses, #empty?
Methods included from Loggable
#log, #log_exception
Methods included from Callbacks
#callbacks_for?, #emit, #on, #once, #only
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
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
|
#connections ⇒ Object
50
51
52
|
# File 'lib/httpx/resolver/system.rb', line 50
def connections
EMPTY
end
|
#handle_socket_timeout(interval) ⇒ Object
95
96
97
98
99
|
# File 'lib/httpx/resolver/system.rb', line 95
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
|
#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
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.origin.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
|