Class: Mongo::Srv::Result Private
- Inherits:
-
Object
- Object
- Mongo::Srv::Result
- Includes:
- Address::Validator
- Defined in:
- lib/mongo/srv/result.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
SRV record lookup result.
Contains server addresses that the query resolved to, and minimum TTL of the DNS records.
Constant Summary collapse
- MISMATCHED_DOMAINNAME =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Returns MISMATCHED_DOMAINNAME Error message format string indicating that an SRV record found does not match the domain of a hostname.
"Parent domain name in SRV record result (%s) does not match " + "that of the hostname (%s)".freeze
Instance Attribute Summary collapse
-
#address_strs ⇒ Array<String>
readonly
private
Address_strs The host strings of the SRV records for the query hostname.
-
#min_ttl ⇒ Integer | nil
private
Min_ttl The smallest TTL found among the records (or nil if no records have been added).
-
#query_hostname ⇒ String
readonly
private
Query_hostname The hostname pointing to the DNS records.
Instance Method Summary collapse
-
#add_record(record) ⇒ Object
private
Adds a new record.
-
#empty? ⇒ Boolean
private
Checks whether there are any records.
-
#initialize(hostname) ⇒ Result
constructor
private
Create a new object to keep track of the SRV records of the hostname.
Methods included from Address::Validator
Constructor Details
#initialize(hostname) ⇒ Result
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Create a new object to keep track of the SRV records of the hostname.
49 50 51 52 53 |
# File 'lib/mongo/srv/result.rb', line 49 def initialize(hostname) @query_hostname = hostname @address_strs = [] @min_ttl = nil end |
Instance Attribute Details
#address_strs ⇒ Array<String> (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns address_strs The host strings of the SRV records for the query hostname.
40 41 42 |
# File 'lib/mongo/srv/result.rb', line 40 def address_strs @address_strs end |
#min_ttl ⇒ Integer | nil
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns min_ttl The smallest TTL found among the records (or nil if no records have been added).
44 45 46 |
# File 'lib/mongo/srv/result.rb', line 44 def min_ttl @min_ttl end |
#query_hostname ⇒ String (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns query_hostname The hostname pointing to the DNS records.
36 37 38 |
# File 'lib/mongo/srv/result.rb', line 36 def query_hostname @query_hostname end |
Instance Method Details
#add_record(record) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Adds a new record.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/mongo/srv/result.rb', line 65 def add_record(record) record_host = normalize_hostname(record.target.to_s) port = record.port validate_hostname!(record_host) validate_same_origin!(record_host) address_str = if record_host.index(':') # IPV6 address "[#{record_host}]:#{port}" else "#{record_host}:#{port}" end @address_strs << address_str if @min_ttl.nil? @min_ttl = record.ttl else @min_ttl = [@min_ttl, record.ttl].min end nil end |
#empty? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Checks whether there are any records.
58 59 60 |
# File 'lib/mongo/srv/result.rb', line 58 def empty? @address_strs.empty? end |