Class: AutomateEm::ResolverJob
- Inherits:
-
Object
- Object
- AutomateEm::ResolverJob
- Includes:
- EM::Deferrable
- Defined in:
- lib/automate-em/core/resolver_pool.rb
Instance Method Summary collapse
-
#initialize(hostname) ⇒ ResolverJob
constructor
A new instance of ResolverJob.
- #resolve ⇒ Object
Constructor Details
#initialize(hostname) ⇒ ResolverJob
Returns a new instance of ResolverJob.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/automate-em/core/resolver_pool.rb', line 42 def initialize(hostname) if IPAddress.valid? hostname self.succeed(hostname) else @hostname = hostname # # Enter self into resolver queue # if EM.reactor_thread? EM.defer do AutomateEm.resolver.schedule(self) end else AutomateEm.resolver.schedule(self) end end end |
Instance Method Details
#resolve ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/automate-em/core/resolver_pool.rb', line 61 def resolve begin ip = Resolv.getaddress(@hostname) EM.schedule do self.succeed(ip) end rescue => e EM.schedule do self.fail(e) end end end |