Class: EventMachine::DNS::Request

### Home Classes Methods

### In Files

- lib/em/resolver.rb

### Parent

Object

### Methods

- ::new
- #receive_answer
- #tick

### Included Modules

- EventMachine::Deferrable

### Files

- ChangeLog
- DEFERRABLES
- EPOLL
- INSTALL
- KEYBOARD
- LEGAL
- LIGHTWEIGHT_CONCURRENCY
- PURE_RUBY
- RELEASE_NOTES
- SMTP
- SPAWNED_PROCESSES
- TODO

### Class/Module Index

Quicksearch

- EventMachine
- EventMachine
- EventMachine::Channel
- EventMachine::Completion
- EventMachine::Connection
- EventMachine::DNS
- EventMachine::DNS::Request
- EventMachine::DNS::RequestIdAlreadyUsed
- EventMachine::DNS::Resolver
- EventMachine::DNS::Socket
- EventMachine::DatagramObject
- EventMachine::DefaultDeferrable
- EventMachine::Deferrable
- EventMachine::DeferrableChildProcess
- EventMachine::Error
- EventMachine::EvmaKeyboard
- EventMachine::EvmaTCPClient
- EventMachine::EvmaTCPServer
- EventMachine::EvmaUDPSocket
- EventMachine::EvmaUNIXClient
- EventMachine::EvmaUNIXServer
- EventMachine::FileNotFoundException
- EventMachine::FileStreamer
- EventMachine::FileWatch
- EventMachine::Iterator
- EventMachine::LoopbreakReader
- EventMachine::PeriodicTimer
- EventMachine::Pool
- EventMachine::ProcessWatch
- EventMachine::Protocols
- EventMachine::Protocols
- EventMachine::Protocols::HeaderAndContentProtocol
- EventMachine::Protocols::HttpClient
- EventMachine::Protocols::HttpClient2
- EventMachine::Protocols::HttpClient2::Request
- EventMachine::Protocols::LineAndTextProtocol
- EventMachine::Protocols::LineProtocol
- EventMachine::Protocols::LineText2
- EventMachine::Protocols::Memcache
- EventMachine::Protocols::Memcache::ParserError
- EventMachine::Protocols::ObjectProtocol
- EventMachine::Protocols::Postgres3
- EventMachine::Protocols::SASLauth
- EventMachine::Protocols::SASLauthclient
- EventMachine::Protocols::SmtpClient
- EventMachine::Protocols::SmtpServer
- EventMachine::Protocols::Socks4
- EventMachine::Protocols::Stomp
- EventMachine::Protocols::Stomp::Message
- EventMachine::Protocols::TcpConnectTester
- EventMachine::Queue
- EventMachine::Reactor
- EventMachine::Selectable
- EventMachine::SpawnedProcess
- EventMachine::StreamObject
- EventMachine::SystemCmd
- EventMachine::ThreadedResource
- EventMachine::TickLoop
- EventMachine::Timer
- EventMachine::UuidGenerator
- EventMachine::YieldBlockFromSpawnedProcess
- Object
- Object::EM
- Object::P
- BufferedTokenizer
- IO
- StringIO
- TestConnection

No matching classes.

# EventMachine::DNS::Request

### Attributes

max_tries[RW]
retry_interval[RW]

### Public Class Methods

new(socket, hostname) click to toggle source

    # File lib/em/resolver.rb, line 138
    def initialize(socket, hostname)
      @socket = socket
      @hostname = hostname
      @tries = 0
      @last_send = Time.at(0)
      @retry_interval = 3
      @max_tries = 5

      if addrs = Resolver.hosts[hostname]
        succeed addrs
      else
        EM.next_tick { tick }
      end
    end

### Public Instance Methods

receive_answer(msg) click to toggle source

    # File lib/em/resolver.rb, line 164
    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

tick() click to toggle source

    # File lib/em/resolver.rb, line 153
    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

[Validate]

Generated with the Darkfish Rdoc Generator 2.