| Class | Mongo::URI::SRVProtocol |
| In: |
lib/mongo/uri/srv_protocol.rb
|
| Parent: | URI |
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
@example Use the uri string to make a client connection.
client = Mongo::Client.new('mongodb+srv://test6.test.build.10gen.cc/')
@since 2.5.0
| RECORD_PREFIX | = | '_mongodb._tcp.'.freeze |
| DOT_PARTITION | = | '.'.freeze |
| VALID_TXT_OPTIONS | = | ['replicaset', 'authsource'].freeze |
| INVALID_HOST | = | "One and only one host is required in a connection string with the " + "'#{MONGODB_SRV_SCHEME}' protocol.".freeze |
| INVALID_PORT | = | "It is not allowed to specify a port in a connection string with the " + "'#{MONGODB_SRV_SCHEME}' protocol.".freeze |
| INVALID_DOMAIN | = | "The domain name must consist of at least two parts: the domain name, " + "and a TLD.".freeze |
| NO_SRV_RECORDS | = | "The DNS query returned no SRV records at hostname (%s)".freeze |
| MORE_THAN_ONE_TXT_RECORD_FOUND | = | "Only one TXT record is allowed. Querying hostname (%s) " + "returned more than one result.".freeze |
| INVALID_TXT_RECORD_OPTION | = | "TXT records can only specify the options " + "[#{VALID_TXT_OPTIONS.join(', ')}].".freeze |
| MISMATCHED_DOMAINNAME | = | "Parent domain name in SRV record result (%s) does not match " + "that of the hostname (%s)".freeze |
| FORMAT | = | 'mongodb+srv://[username:password@]host[/[database][?options]]'.freeze |
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.
@example Get the client options.
uri.client_options
@return [ Hash ] The options passed to the Mongo::Client
@since 2.5.0