Class: Mongo::URI::SRVProtocol
- Inherits:
-
Mongo::URI
- Object
- Mongo::URI
- Mongo::URI::SRVProtocol
- Defined in:
- build/ruby-driver-v2.19/lib/mongo/uri/srv_protocol.rb
Overview
Parser for a URI using the mongodb+srv protocol, which specifies a DNS to query for SRV records. The driver will query the DNS server for SRV records on <hostname>.<domainname>, prefixed with _mongodb._tcp The SRV records can then be used as the seedlist for a Mongo::Client. The driver also queries for a TXT record providing default connection string options. Only one TXT record is allowed, and only a subset of Mongo::Client options is allowed.
Please refer to the Initial DNS Seedlist Discovery spec for details.
github.com/mongodb/specifications/blob/master/source/initial-dns-seedlist-discovery
Constant Summary
Constants inherited from Mongo::URI
AUTH_DELIM, AUTH_MECH_MAP, AUTH_USER_PWD_DELIM, DATABASE_DELIM, HELP, HOST_DELIM, HOST_PORT_DELIM, INDIV_URI_OPTS_DELIM, INVALID_OPTS_DELIM, INVALID_OPTS_VALUE_DELIM, INVALID_SCHEME, MONGODB_SCHEME, MONGODB_SRV_SCHEME, PERCENT_CHAR, READ_MODE_MAP, REPEATABLE_OPTIONS, SCHEME, SCHEME_DELIM, UNESCAPED_DATABASE, UNESCAPED_UNIX_SOCKET, UNESCAPED_USER_PWD, UNIX_SOCKET, UNSAFE, URI_OPTS_DELIM, URI_OPTS_VALUE_DELIM
Constants included from Loggable
Instance Attribute Summary collapse
-
#query_hostname ⇒ String
readonly
private
The hostname that is specified in the URI and used to look up SRV records.
- #srv_records ⇒ Object readonly
-
#srv_result ⇒ Srv::Result
readonly
private
SRV lookup result.
Attributes inherited from Mongo::URI
#options, #servers, #uri_options
Instance Method Summary collapse
-
#client_options ⇒ Hash
Gets the options hash that needs to be passed to a Mongo::Client on instantiation, so we don’t have to merge the txt record options, credentials, and database in at that point - we only have a single point here.
Methods inherited from Mongo::URI
#credentials, #database, get, #initialize, #to_s
Methods included from Address::Validator
Methods included from Loggable
#log_debug, #log_error, #log_fatal, #log_info, #log_warn, #logger
Constructor Details
This class inherits a constructor from Mongo::URI
Instance Attribute Details
#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.
The hostname that is specified in the URI and used to look up SRV records.
This attribute needs to be defined because SRVProtocol changes #servers to be the result of the lookup rather than the hostname specified in the URI.
72 73 74 |
# File 'build/ruby-driver-v2.19/lib/mongo/uri/srv_protocol.rb', line 72 def query_hostname @query_hostname end |
#srv_records ⇒ Object (readonly)
39 40 41 |
# File 'build/ruby-driver-v2.19/lib/mongo/uri/srv_protocol.rb', line 39 def srv_records @srv_records end |
#srv_result ⇒ Srv::Result (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 SRV lookup result.
60 61 62 |
# File 'build/ruby-driver-v2.19/lib/mongo/uri/srv_protocol.rb', line 60 def srv_result @srv_result end |
Instance Method Details
#client_options ⇒ Hash
Gets the options hash that needs to be passed to a Mongo::Client on instantiation, so we don’t have to merge the txt record options, credentials, and database in at that point - we only have a single point here.
51 52 53 54 55 |
# File 'build/ruby-driver-v2.19/lib/mongo/uri/srv_protocol.rb', line 51 def opts = @txt_options.merge(ssl: true) opts = opts.merge().merge(:database => database) @user ? opts.merge(credentials) : opts end |