Skip to content

RUBY-1559 Implement uri option spec tests #1170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Dec 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 101 additions & 55 deletions docs/tutorials/ruby-driver-create-client.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ Since the URI options are required in camel case, which is not the Ruby standard
following table shows the option in the URI and its corresponding option if passed
to the constructor in Ruby.

.. note::
.. note::

The options passed directly should be symbols.

The options are explained in detail in the :manual:`Connection URI reference
</reference/connection-string/>`.
</reference/connection-string/>`.

.. note::
Options that are set in **milliseconds** in the URI are
Expand All @@ -97,8 +97,29 @@ URI Options Conversions
* - URI Option
- Ruby Option

* - replicaSet=String
- ``:replica_set => String``
* - appName=String
- ``:app_name => String``

* - authMechanism=String
- ``:auth_mech => Symbol``

* - authMechanismProperties=Strings
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would a user determine what to put in Strings for this option?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This already existed in the old code; I just alphabetized the list for easier reading. If you just look at the diff for e396935, you'll see the options that are new.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added extra documentation to this option and the others below where the type being forwarded is different from the type specified in the URI. Let me know if you think any of the other options need extra documentation as well.

- ``{ :auth_mech_properties => { :service_realm => String, :canonicalize_host_name => true|false, :service_name => String } }``

Specified as comma-separated key:value pairs, e.g. ``"SERVICE_REALM:foo,CANONICALIZE_HOSTNAME:TRUE"``.

* - authSource=String
- ``:auth_source => String``

* - compressors=Strings
- ``:compressors => Array<String>``

Specified as a comma-separated list. Note that the Ruby driver only supports zlib
compression; however, other drivers may support snappy. For maximum compatibility with
drivers, specify ``"snappy,zlib"``; if compatibility with other drivers is not a concern,
specify ``"zlib".`` Compression is not enabled by default and when using MongoDB 4.0 and
earlier, so zlib compression must be manually enabled on the server in order for the Ruby
driver to compress wire protocol data.

* - connect=String
- ``:connect => Symbol``
Expand All @@ -109,56 +130,81 @@ URI Options Conversions
* - connectTimeoutMS=Integer
- ``:connect_timeout => Float``

* - socketTimeoutMS=Integer
- ``:socket_timeout => Float``
* - fsync=Boolean
- ``{ :write => { :fsync => true|false }}``

* - serverSelectionTimeoutMS=Integer
- ``:server_selection_timeout => Float``
* - heartbeatFrequencyMS=Integer
- ``:heartbeat_frequency => Float``

* - journal=Boolean
- ``{ :write => { :j => true|false }}``

* - localThresholdMS=Integer
- ``:local_threshold => Float``

* - maxIdleTimeMS=Integer
- ``:max_idle_time => Float``

* - maxPoolSize=Integer
- ``:max_pool_size => Integer``

* - minPoolSize=Integer
- ``:min_pool_size => Integer``

* - waitQueueTimeoutMS=Integer
- ``:wait_queue_timeout => Float``
* - readPreference=String
- ``{ :read => { :mode => Symbol }}``

* - w=Integer|String
- ``{ :write => { :w => Integer|String }}``
* - readPreferenceTags=Strings
- ``{ :read => { :tag_sets => Array<Hash> }}``

* - wtimeoutMS=Integer
- ``{ :write => { :wtimeout => Float }}``
Each instance of the readPreferenceTags field is a comma-separated key:value pair which will appear in the :tag_sets array in the order they are specified. For instance, ``"readPreferenceTags=dc:ny,rack:1&readPreferenceTags=dc:ny"`` will be converted to ``[ { 'dc' => 'ny', 'rack' => '1' }, { 'dc' => 'ny' }]``.

* - journal=Boolean
- ``{ :write => { :j => true|false }}``
* - replicaSet=String
- ``:replica_set => String``

* - fsync=Boolean
- ``{ :write => { :fsync => true|false }}``
* - serverSelectionTimeoutMS=Integer
- ``:server_selection_timeout => Float``

* - readPreference=String
- ``{ :read => { :mode => Symbol }}``
* - socketTimeoutMS=Integer
- ``:socket_timeout => Float``

* - readPreferenceTags=Strings
- ``{ :read => { :tag_sets => Array<String> }}``
* - tls=Boolean
- ``:ssl => boolean``

* - authSource=String
- ``:auth_source => String``
* - tlsAllowInvalidCertificates=Boolean
- ``:ssl_verify => boolean``

* - authMechanism=String
- ``:auth_mech => Symbol``
Because ``tlsAllowInvalidCertificates`` uses ``true`` to signify that verification
should be disabled and ``ssl_verify`` uses ``false`` to signify that verification should be
disabled, the boolean is inverted before being used to set ``ssl_verify``.

* - authMechanismProperties=Strings
- ``{ :auth_mech_properties => { :service_realm => String, :canonicalize_host_name => true|false, :service_name => String } }``
* - tlsCAFile=String
- ``:ssl_ca_cert => String``

* - appName=String
- ``:app_name => String``
* - tlsClientCertFile=String
- ``:ssl_cert => String``

* - compressors=Strings
- ``:compressors => Array<String>``
* - tlsClientKeyFile=String
- ``:ssl_key => String``

* - tlsClientKeyPassword=String
- ``:ssl_key_pass_phrase => String``

* - tlsInsecure=Boolean
- ``:ssl_verify => boolean``

Because tlsInsecure uses ``true`` to signify that verification should be disabled and
``ssl_verify`` uses ``false`` to signify that verification should be disabled, the boolean
is inverted before being used to set ``ssl_verify``.

* - w=Integer|String
- ``{ :write => { :w => Integer|String }}``

* - waitQueueTimeoutMS=Integer
- ``:wait_queue_timeout => Float``

* - wtimeoutMS=Integer
- ``{ :write => { :wtimeout => Float }}``

* - zlibCompressionLevel=Integer
- ``:zlib_compression_level => Integer``
Expand All @@ -178,12 +224,12 @@ Ruby Options

* - ``:replica_set``
- When connecting to a replica set, this is the name of the set to
filter servers by.
filter servers by.
- ``String``
- none

* - ``:ssl``
- Tell the client to connect to the servers via SSL.
- Tell the client to connect to the servers via SSL.
- ``Boolean``
- false

Expand Down Expand Up @@ -255,30 +301,30 @@ Ruby Options

* - ``:connect_timeout``
- The number of seconds to wait to establish a socket connection
before raising an exception.
before raising an exception.
- ``Float``
- 10 seconds

* - ``:socket_timeout``
- The number of seconds to wait for an operation to execute on a
socket before raising an exception.
socket before raising an exception.
- ``Float``
- 5 seconds

* - ``:max_pool_size``
- The maximum size of the connection pool for each server.
- The maximum size of the connection pool for each server.
- ``Integer``
- 5

* - ``:min_pool_size``
- The minimum number of connections in the connection pool for each
server.
server.
- ``Integer``
- 1

* - ``:wait_queue_timeout``
- The number of seconds to wait for a connection in the connection
pool to become available.
pool to become available.
- ``Float``
- 1

Expand All @@ -291,22 +337,22 @@ Ruby Options
{ :write => { :w => 2 } }
- ``Hash``
- ``{ :w => 1 }``

* - ``:read``
- Specifies the read preference mode and tag sets for selecting servers as a ``Hash``.
Keys in the hash are ``:mode`` and ``:tag_sets``.

.. code-block:: ruby

{ :read =>
{ :mode => :secondary,
:tag_sets => [ "berlin" ]
}
{ :read =>
{ :mode => :secondary,
:tag_sets => [ "berlin" ]
}
}

- ``Hash``
- ``{ :mode => :primary }``

* - ``:auth_source``
- Specifies the authentication source.
- ``String``
Expand All @@ -316,7 +362,7 @@ Ruby Options

* - ``:auth_mech``
- Specifies the authenticaion mechanism to use. Can be one of:
``:mongodb_cr``, ``:mongodb_x509``, ``:plain``, ``:scram``.
``:mongodb_cr``, ``:mongodb_x509``, ``:plain``, ``:scram``.
- ``Symbol``
- MongoDB 3.0 and later: ``:scram`` if user credentials
are supplied but an ``:auth_mech`` is not. 2.6 and earlier:
Expand All @@ -343,7 +389,7 @@ Ruby Options
``:replica_set`` or ``:sharded``.
- ``Symbol``
- none

* - ``:heartbeat_frequency``
- The number of seconds for the server monitors to refresh
server states asynchronously.
Expand Down Expand Up @@ -437,9 +483,9 @@ Details on Timeout Options

``connect_timeout``
On initialization of a connection to a server, this setting is the
number of seconds to wait to connect before raising an exception.
number of seconds to wait to connect before raising an exception.
This timeout is also used when monitor threads ping their servers.
The default is 10 seconds. See the `socket timeout for monitoring
The default is 10 seconds. See the `socket timeout for monitoring
specification <https://github.com/mongodb/specifications/blob/
master/source/server-discovery-and-monitoring/server-discovery-and-monitoring.rst#socket-timeout-for-monitoring
-is-connecttimeoutms>`_ for further explanation.
Expand All @@ -457,7 +503,7 @@ Details on Timeout Options
The number of seconds to wait for the driver to find an appropriate server to
which an operation can be sent before raising an exception. Defaults to 30.
It should take the speed of :manual:`elections</core/replica-set-elections/>`
during a failover into account. See the
during a failover into account. See the
`serverSelectionTimeoutMS specification
<https://github.com/mongodb/specifications/blob/master/source/server-selection/server-selection.rst#serverselectiontimeoutms>`_
for further information.
Expand All @@ -466,10 +512,10 @@ Details on Timeout Options
The maximum latency in seconds between the nearest server and the servers that can be considered available to send an
operation to. Defaults to 0.015.

.. note::
.. note::
This is not the latency window between the driver and a server, but
rather the latency between the nearest server and other servers. See
`the localThresholdMS specification
`the localThresholdMS specification
<https://github.com/mongodb/specifications/blob/master/source/server-selection/server-selection.rst#localthresholdms>`_.

``wait_queue_timeout``
Expand All @@ -483,7 +529,7 @@ Details on Timeout Options

``min_pool_size``
Minimum number of connections in the connection pool for each server.
Increase this number to create connections when the pool is
Increase this number to create connections when the pool is
initialized and to reduce the overhead of creating new connections
later on. Defaults to 1.

Expand Down Expand Up @@ -669,7 +715,7 @@ You can either use the default global driver logger or set your own. To set your
Mongo::Logger.logger = other_logger

See the `Ruby Logger documentation <http://ruby-doc.org/stdlib-2.2.0/libdoc/logger/rdoc/Logger.html>`_
for more information on the default logger API and available levels.
for more information on the default logger API and available levels.

Changing the Logger Level
`````````````````````````
Expand Down
Loading