Skip to content

Commit 362b4e1

Browse files
authored
RUBY-2746 RUBY-2851 RUBY-2737 Provide options to limit number of mongos servers used in connecting to sharded clusters (#2380)
* RUBY-2746 add spec tests * RUBY-2746 add another spec test * RUBY-2746 implemented srvServiceName, 5 tests still failing * RUBY-2746 added srvMaxHosts implementation and fix test for it * RUBY-2746 add type that raises error on no parse, ALL TESTS PASSING * RUBY-2746 move uri validation for replica set * RUBY-2746 uri options passing, still waiting on bad input failure direction * RUBY-2746 remove offending tests and integer_raise * RUBY-2746 clean up old test files and combine runners * RUBY-2746 add support for ruby options * RUBY-2746 add tests for ruby options * RUBY-2746 cleanup comments * RUBY-2746 fix tests, naming, method signatures, set srv_max_hosts to nil on 0 * RUBY-2746 don't set srv_max_hosts on 0 * RUBY-2746 add docs for new options * RUBY-2746 fix bug, add test for srv_max_hosts * RUBY-2746 add tests for different valus of srvMaxHosts * RUBY-2746 add srvServiceName test * RUBY-2746 fix spec tests, make srv_max_hosts accept 0 * RUBY-2746 fix srv tests, disregard sorting * RUBY-2746 fix tests sorting * RUBY-2746 update comments and docs
1 parent 13a2edd commit 362b4e1

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

source/reference/create-client.txt

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ routers explicitly, the driver will not discover remaining routers that
235235
may be configured and will not attempt to connect to them.
236236

237237
The driver will automatically balance the operation load among the routers
238-
it is aware of.
238+
it is aware of.
239239

240240
To connect to a MongoDB Atlas cluster which is deployed as a sharded cluster,
241241
connect to the URI:
@@ -537,7 +537,7 @@ Ruby Options
537537
* - ``:max_idle_time``
538538
- The maximum time, in seconds, that a connection can be idle before it
539539
is closed by the connection pool.
540-
540+
541541
*Warning:* when connected to a load balancer, the driver uses existing
542542
connections for iterating cursors (which includes change streams)
543543
and executing transactions. Setting an idle time via this option may
@@ -669,11 +669,11 @@ Ruby Options
669669
- ``:version`` (String)
670670
- ``:strict`` (true or false)
671671
- ``:deprecation_errors`` (true or false)
672-
672+
673673
Note that the server API version can only be specified as a Ruby option,
674674
not as a URI option, and it cannot be overridden for database and
675675
collection objects.
676-
676+
677677
If server API version is changed on a client (such as via the ``with``
678678
call), the entire API version hash is replaced with the new specification
679679
(the old and the new individual fields are NOT merged).
@@ -694,6 +694,24 @@ Ruby Options
694694
- ``Float``
695695
- none
696696

697+
* - ``:srv_max_hosts``
698+
- The maximum number of mongoses that the driver will communicate with
699+
for sharded topologies. If this option is set to 0, there will
700+
be no maximum number of mongoses. If the given URI resolves
701+
to more hosts than ``:srv_max_hosts``, the client will ramdomly
702+
choose an ``:srv_max_hosts`` sized subset of hosts. Note that the
703+
hosts that the driver ignores during client construction will never
704+
be used. If the hosts chosen by the driver become unavailable, the
705+
client will quit working completely, even though the deployment has
706+
other functional mongoses.
707+
- ``Integer``
708+
- 0
709+
710+
* - ``:srv_service_name``
711+
- The service name to use in the SRV DNS query.
712+
- ``String``
713+
- mongodb
714+
697715
* - ``:ssl``
698716
- Tell the client to connect to the servers via TLS.
699717
- ``Boolean``
@@ -1012,6 +1030,12 @@ URI options are explained in detail in the :manual:`Connection URI reference
10121030
invalid values (e.g. negative and non-numeric values), invalid values
10131031
provided via this URI option are ignored with a warning.
10141032

1033+
* - srvMaxHosts=Integer
1034+
- ``:srv_max_hosts => Integer``
1035+
1036+
* - srvServiceName=String
1037+
- ``:srv_service_name => String``
1038+
10151039
* - ssl=Boolean
10161040
- ``:ssl => true|false``
10171041

@@ -1874,7 +1898,7 @@ the highest compression at the same CPU consumption compared to the other
18741898
compressors. For maximum server compatibility all three compressors can be
18751899
specified, e.g. as ``compressors: ["zstd", "snappy", "zlib"]``.
18761900

1877-
``zstd`` compressor requires the
1901+
``zstd`` compressor requires the
18781902
`zstd-ruby <https://rubygems.org/gems/zstd-ruby>`_ library to be installed.
18791903
``snappy`` compressor requires the
18801904
`snappy <https://rubygems.org/gems/snappy>`_ library to be installed.

0 commit comments

Comments
 (0)