Class: EventMachine::DNS::Request
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
self,
Deferrable
|
|
Inherits: | Object |
Defined in: | lib/em/resolver.rb |
Constant Summary
Deferrable
- Included
Class Method Summary
- .new(socket, hostname) ⇒ Request constructor
Instance Attribute Summary
- #max_tries rw
- #retry_interval rw
Instance Method Summary
- #receive_answer(msg)
- #tick
- #id private
- #packet private
- #send private
Deferrable
- Included
#callback | Specify a block to be executed if and when the |
#cancel_callback | Cancels an outstanding callback to &block if any. |
#cancel_errback | Cancels an outstanding errback to &block if any. |
#cancel_timeout | Cancels an outstanding timeout if any. |
#errback | Specify a block to be executed if and when the |
#fail | Sugar for set_deferred_status(:failed, ...). |
#set_deferred_failure | Alias for EventMachine::Deferrable#fail. |
#set_deferred_status | Sets the "disposition" (status) of the |
#set_deferred_success | Alias for EventMachine::Deferrable#succeed. |
#succeed | Sugar for set_deferred_status(:succeeded, ...). |
#timeout | Setting a timeout on a |
Constructor Details
.new(socket, hostname) ⇒ Request
Instance Attribute Details
#max_tries (rw)
[ GitHub ]# File 'lib/em/resolver.rb', line 159
attr_accessor :retry_interval, :max_tries
#retry_interval (rw)
[ GitHub ]# File 'lib/em/resolver.rb', line 159
attr_accessor :retry_interval, :max_tries
Instance Method Details
#id (private)
[ GitHub ]# File 'lib/em/resolver.rb', line 211
def id begin @id = rand(65535) @socket.register_request(@id, self) rescue RequestIdAlreadyUsed retry end unless defined?(@id) @id end
#packet (private)
[ GitHub ]#receive_answer(msg)
[ GitHub ]# File 'lib/em/resolver.rb', line 187
def receive_answer(msg) addrs = [] msg.each_answer do |name,ttl,data| if data.kind_of?(Resolv::DNS::Resource::IN::A) || data.kind_of?(Resolv::DNS::Resource::IN::AAAA) addrs << data.address.to_s end end if addrs.empty? fail "rcode=#{msg.rcode}" else succeed addrs end end
#send (private)
[ GitHub ]# File 'lib/em/resolver.rb', line 205
def send @tries += 1 @last_send = Time.now @socket.send_packet(packet.encode) end
#tick
[ GitHub ]# File 'lib/em/resolver.rb', line 176
def tick # Break early if nothing to do return if @last_send + @retry_interval > Time.now if @tries < @max_tries send else @socket.deregister_request(@id, self) fail 'retries exceeded' end end