SRVProtocol — Documentation by YARD 0.9.37 (original) (raw)

Class: Mongo::URI::SRVProtocol

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 ., 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/initial-dns-seedlist-discovery.md

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

Loggable::PREFIX

Instance Attribute Summary collapse

Attributes inherited from Mongo::URI

#options, #servers, #uri_options

Instance Method Summarycollapse

Methods inherited from Mongo::URI

#credentials, #database, get, #initialize, #to_s

Methods included from Address::Validator

#validate_address_str!

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

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 'lib/mongo/uri/srv_protocol.rb', line 72 def query_hostname @query_hostname end

#srv_records ⇒ Object

39 40 41 # File 'lib/mongo/uri/srv_protocol.rb', line 39 def srv_records @srv_records end

#srv_resultSrv::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.

Returns SRV lookup result.

60 61 62 # File '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 'lib/mongo/uri/srv_protocol.rb', line 51 def client_options opts = @txt_options.merge(ssl: true) opts = opts.merge(uri_options).merge(:database => database) @user ? opts.merge(credentials) : opts end