Class: Coolio::DNSResolver::Timeout

Inherits:
TimerWatcher show all
Defined in:
lib/cool.io/dns_resolver.rb

Instance Method Summary collapse

Methods inherited from TimerWatcher

#attach, #detach, #disable, #enable, #reset

Methods included from Meta

#event_callback, #watcher_delegate

Methods inherited from Watcher

#attach, #attached?, #detach, #disable, #enable, #enabled?, #evloop

Constructor Details

#initialize(resolver) ⇒ Timeout

Returns a new instance of Timeout.



208
209
210
211
212
# File 'lib/cool.io/dns_resolver.rb', line 208

def initialize(resolver)
  @resolver = resolver
  @attempts = 0
  super(TIMEOUT, true)
end

Instance Method Details

#on_timerObject



214
215
216
217
218
219
220
221
222
223
224
225
# File 'lib/cool.io/dns_resolver.rb', line 214

def on_timer
  @attempts += 1
  if @attempts <= RETRIES
    begin
      return @resolver.__send__(:send_request)
    rescue Errno::EHOSTUNREACH # if the DNS is toast try again after the timeout occurs again
      return nil
    end
  end
  @resolver.__send__(:on_timeout)
  @resolver.detach
end