Class: Libuv::Dns
- Inherits:
-
Q::DeferredPromise
- Object
- Q::Promise
- Q::DeferredPromise
- Libuv::Dns
- Defined in:
- lib/libuv/dns.rb
Constant Summary collapse
- HINTS =
{ :IPv4 => ::Libuv::Ext::UvAddrinfo.new, :IPv6 => ::Libuv::Ext::UvAddrinfo.new }
Constants included from Net
Net::INET6_ADDRSTRLEN, Net::INET_ADDRSTRLEN, Net::IP_ARGUMENT_ERROR, Net::PORT_ARGUMENT_ERROR
Constants inherited from Q::Promise
Instance Attribute Summary collapse
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#hint ⇒ Object
readonly
Returns the value of attribute hint.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#results ⇒ Object
readonly
Returns the value of attribute results.
Attributes inherited from Q::Promise
Instance Method Summary collapse
-
#completed? ⇒ true, false
Indicates if the lookup has completed yet or not.
-
#initialize(reactor, domain, port, hint = :IPv4, wait: true) ⇒ Dns
constructor
A new instance of Dns.
Methods included from Resource
#check_result, #check_result!, #resolve, #to_ptr
Methods inherited from Q::DeferredPromise
Methods inherited from Q::Promise
#catch, #finally, #progress, #ruby_catch, #value
Constructor Details
#initialize(reactor, domain, port, hint = :IPv4, wait: true) ⇒ Dns
Returns a new instance of Dns.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/libuv/dns.rb', line 36 def initialize(reactor, domain, port, hint = :IPv4, wait: true) super(reactor, reactor.defer) @domain = domain @port = port @hint = hint @complete = false @pointer = ::Libuv::Ext.allocate_request_getaddrinfo @error = nil # error in callback @instance_id = @pointer.address error = check_result ::Libuv::Ext.getaddrinfo(@reactor, @pointer, callback(:on_complete), domain, port.to_s, HINTS[hint]) if error ::Libuv::Ext.free(@pointer) @complete = true @defer.reject(error) end co(@defer.promise) if wait end |
Instance Attribute Details
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
12 13 14 |
# File 'lib/libuv/dns.rb', line 12 def domain @domain end |
#hint ⇒ Object (readonly)
Returns the value of attribute hint.
14 15 16 |
# File 'lib/libuv/dns.rb', line 14 def hint @hint end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
13 14 15 |
# File 'lib/libuv/dns.rb', line 13 def port @port end |
#results ⇒ Object (readonly)
Returns the value of attribute results.
11 12 13 |
# File 'lib/libuv/dns.rb', line 11 def results @results end |
Instance Method Details
#completed? ⇒ true, false
Indicates if the lookup has completed yet or not.
61 62 63 |
# File 'lib/libuv/dns.rb', line 61 def completed? return @complete end |