Skip to content

Commit 24310fa

Browse files
authored
DOCSP-30524: connection options technical review (#36)
1 parent dc716ce commit 24310fa

File tree

5 files changed

+96
-68
lines changed

5 files changed

+96
-68
lines changed

source/fundamentals/connections/connection-guide.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ Connection Guide
1010
:depth: 2
1111
:class: singlecol
1212

13-
In this guide, you can learn how to connect to a MongoDB instance or replica set
14-
deployment using the {+driver-short+}.
13+
Overview
14+
--------
15+
16+
In this guide, you can learn how to connect to a MongoDB instance or
17+
replica set deployment by using the {+driver-short+}.
1518

1619
.. _rust-connection-uri:
1720

18-
--------------
1921
Connection URI
2022
--------------
2123

@@ -135,7 +137,6 @@ connection code samples.
135137

136138
.. _rust-other-ways-to-connect:
137139

138-
--------------------------------
139140
Other Ways to Connect to MongoDB
140141
--------------------------------
141142

source/fundamentals/connections/connection-options.txt

Lines changed: 89 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,13 @@
44
Connection Options
55
==================
66

7-
.. contents:: On this page
8-
:local:
9-
:backlinks: none
10-
:depth: 2
11-
:class: singlecol
7+
Overview
8+
--------
129

1310
In this guide, you can learn about MongoDB connection and authentication
14-
options. You can pass connection options as parameters of the connection
15-
string URI to specify the behavior of the client. To learn more about connection strings, see
16-
:manual:`Connection Strings </reference/connection-string>` in the Server manual.
11+
options. You can set connection options as parameters of your
12+
connection string to specify how your ``Client`` instance behaves while
13+
connected to the server.
1714

1815
.. TODO link to the authentication mechanisms guide in authMechanism below
1916
.. (https://github.com/mongodb/docs-rust/pull/29)
@@ -30,51 +27,55 @@ string URI to specify the behavior of the client. To learn more about connection
3027
* - **appName**
3128
- String
3229
- None
33-
- Specifies the application name that the ``Client`` instance sends to the server as part of the handshake.
34-
Specifying an ``appName`` can help you use the server logs to determine which ``Client`` instance is connected
35-
to the server.
30+
- | Specifies the application name that the ``Client`` instance sends
31+
to the server as part of the handshake.
32+
| Specifying an ``appName`` can help you use the server logs to
33+
determine which ``Client`` instance is connected to the server.
3634

3735
* - **authMechanism**
3836
- String
3937
- None
40-
- Specifies which authentication mechanism to use.
41-
If you do not specify this option, the driver uses the default authentication mechanism.
38+
- Specifies which authentication mechanism to use. If you do not
39+
specify this option, the driver uses the default authentication
40+
mechanism.
4241

4342
* - **authMechanismProperties**
4443
- String
4544
- None
46-
- Specifies additional properties for the authentication mechanism set in the ``authMechanism`` option.
47-
specified in the ``authMechanism`` option.
45+
- Specifies additional properties for the authentication mechanism
46+
set in the ``authMechanism`` option.
4847

4948
* - **authSource**
5049
- String
5150
- See description
52-
- Specifies the database used to authenticate.
53-
This option defaults to ``admin`` for SCRAM-based authentication mechanisms,
54-
``$external`` for the ``MONGODB-X509`` mechanism, and the database name or
55-
``$external`` for the ``PLAIN`` mechanism.
51+
- | Specifies the database used to authenticate.
52+
| This option defaults to ``admin`` for SCRAM-based authentication mechanisms,
53+
``$external`` for the ``MONGODB-X509`` mechanism, and the database name or
54+
``$external`` for the ``PLAIN`` mechanism.
5655

5756
* - **compressors**
5857
- A comma-separated list of strings
5958
- None
6059
- Specifies compressors that the ``Client`` instance uses in the specified order.
6160
To learn more about network compression, see the :ref:`rust-network-compression` guide.
6261

63-
* - ***connectTimeoutMS***
62+
* - **connectTimeoutMS**
6463
- Non-negative integer
6564
- ``10000`` (10 seconds)
66-
- Specifies the connection timeout, in milliseconds, passed to each underlying TCP stream when attempting to connect to the server.
65+
- Specifies the connection timeout, in milliseconds, passed to each
66+
underlying TCP stream when attempting to connect to the server.
6767

68-
* - **direct**
68+
* - **directConnection**
6969
- Boolean
7070
- ``false``
7171
- Specifies whether the ``Client`` instance directly connects to a single host
72-
instead of discovering and connecting to all of the servers in the cluster.
72+
instead of discovering and connecting to all servers in the cluster.
7373

7474
* - **heartbeatFrequencyMS**
7575
- Integer greater than or equal to 500
7676
- ``10000`` (10 seconds)
77-
- Specifies the amount of time, in milliseconds, that each monitoring thread waits between performing server checks.
77+
- Specifies the amount of time, in milliseconds, that each
78+
monitoring thread waits between performing server checks.
7879

7980
* - **journal**
8081
- Boolean
@@ -84,38 +85,46 @@ string URI to specify the behavior of the client. To learn more about connection
8485
* - **localThresholdMS**
8586
- Non-negative integer
8687
- 15
87-
- Specifies how much longer, in milliseconds, that the average round trip time between the driver and server can take
88-
compared to the shortest round trip time of all the suitable servers.
89-
A value of ``0`` indicates that there is no latency window, so only the server with the lowest average round trip time is eligible.
88+
- | Specifies how much longer, in milliseconds, that the average
89+
round-trip time between the driver and server can take
90+
compared to the shortest round-trip time of all the suitable servers.
91+
| A value of ``0`` indicates that there is no latency window, so
92+
only the server with the lowest average round-trip time is
93+
eligible.
9094

9195
* - **maxIdleTimeMS**
9296
- Non-negative integer
9397
- 0
94-
- Specifies the amount of time, in milliseconds, that a connection can remain idle in a connection pool the server closes it.
95-
A value of ``0`` indicates that the client does not close idle connections.
98+
- | Specifies the amount of time, in milliseconds, that a connection
99+
can remain idle in a connection pool the server closes it.
100+
| A value of ``0`` indicates that the client does not close idle
101+
connections.
96102

97103
* - **maxStalenessSeconds**
98104
- ``-1``, or any integer greater than or equal to ``90``
99105
- ``-1``
100-
- Specifies the maximum lag, in seconds, behind the primary node that a secondary node can be to be
101-
considered for the given operation.
102-
103-
The value of this option must be at least ``90``, or the operation raises an error.
104-
A value of ``-1`` means there is no maximum lag.
106+
- | Specifies the maximum lag, in seconds, behind the primary node
107+
that a secondary node can be to be considered for the given operation.
108+
| The value of this option must be at least ``90``, or the
109+
operation raises an error. A value of ``-1`` means there is no
110+
maximum lag.
105111

106112
* - **maxPoolSize**
107113
- Non-negative integer
108114
- ``10``
109-
- Specifies the maximum number of connections that the ``Client`` instance can create in a connection pool for a given server.
110-
If you attempt an operation while the value of ``maxPoolSize`` connections are checked out,
111-
the operation waits until an in-progress operation finishes and the connection returns to the pool.
115+
- | Specifies the maximum number of connections that the ``Client``
116+
instance can create in a connection pool for a given server.
117+
| If you attempt an operation while the value of ``maxPoolSize``
118+
connections are checked out, the operation waits until an
119+
in-progress operation finishes and the connection returns to the pool.
112120

113121
* - **minPoolSize**
114122
- Non-negative integer
115123
- ``0``
116-
- Specifies the minimum number of connections that are available in a server's connection pool at a given time.
117-
If fewer than ``minPoolSize`` connections are in the pool,
118-
the server adds connections in the background up to the value of ``minPoolSize``.
124+
- | Specifies the minimum number of connections that are available in
125+
a server's connection pool at a given time.
126+
| If fewer than ``minPoolSize`` connections are in the pool,
127+
the server adds connections in the background up to the value of ``minPoolSize``.
119128

120129
* - **readConcernLevel**
121130
- String
@@ -134,7 +143,8 @@ string URI to specify the behavior of the client. To learn more about connection
134143
- None
135144
- Specifies which replica set members are considered for operations.
136145
Each instance of this key is a separate tag set.
137-
The driver checks each tag set until it finds one or more servers with each tag in the set.
146+
The driver checks each tag set until it finds one or more servers
147+
with each tag in the set.
138148

139149
* - **replicaSet**
140150
- String
@@ -149,7 +159,9 @@ string URI to specify the behavior of the client. To learn more about connection
149159
* - **serverSelectionTimeoutMS**
150160
- Non-negative integer
151161
- ``30000`` (30 seconds)
152-
- Specifies the amount of time, in milliseconds, that the ``Client`` instance waits when attempting to select a server for an operation before timing out.
162+
- Specifies the amount of time, in milliseconds, that the
163+
``Client`` instance waits when attempting to select a server for an
164+
operation before timing out.
153165

154166
* - **tls**
155167
- Boolean
@@ -159,47 +171,62 @@ string URI to specify the behavior of the client. To learn more about connection
159171

160172
* - **tlsAllowInvalidCertificates**
161173
- Boolean
162-
- ``true``
163-
- Specifies whether the ``Client`` instance returns an error if the server presents an invalid certificate.
164-
We recommend that you set this option to ``true`` only in testing environments to avoid creating vulnerabilities in your application.
174+
- ``false``
175+
- | Specifies whether the ``Client`` instance returns an error if the
176+
server presents an invalid certificate.
177+
| We recommend that you set this option to ``true`` only in
178+
testing environments to avoid creating vulnerabilities in your
179+
application.
165180

166181
* - **tlsCAFile**
167182
- String
168183
- See description
169-
- Specifies the path to the certificate authority (CA) file that the ``Client`` instance uses for TLS.
170-
If you do not specify this option, the driver uses the Mozilla root certificates from the ``webpki-roots`` crate.
184+
- | Specifies the path to the certificate authority (CA) file that
185+
the ``Client`` instance uses for TLS.
186+
| If you do not specify this option, the driver uses the Mozilla
187+
root certificates from the ``webpki-roots`` crate.
171188

172189
* - **tlsCertificateKeyFile**
173190
- String
174191
- None
175-
- Specifies the path to the certificate file that the ``Client`` instance presents to the server to verify its identify.
176-
If you do not set this option, the ``Client`` instance does not attempt to verify its identity to the server.
192+
- | Specifies the path to the certificate file that the ``Client``
193+
instance presents to the server to verify its identify.
194+
| If you do not set this option, the ``Client`` instance does not
195+
attempt to verify its identity to the server.
177196

178197
* - **tlsInsecure**
179198
- Boolean
180-
- ``true``
181-
- Specifies whether the ``Client`` instance returns an error if the server presents an invalid certificate.
182-
We recommend that you set this option to ``true`` only in testing environments to avoid creating vulnerabilities in your application.
199+
- ``false``
200+
- | Specifies whether the ``Client`` instance returns an error if the
201+
server presents an invalid certificate.
202+
| We recommend that you set this option to ``true`` only in
203+
testing environments to avoid creating vulnerabilities in your
204+
application.
183205

184206
* - **w**
185207
- Non-negative integer or string
186208
- None
187-
- Requests acknowledgment that the operation has propagated to a specific number or variety of servers.
188-
To learn more, see :manual:`Write Concern </reference/write-concern>` in the Server manual.
209+
- | Requests acknowledgment that the operation has propagated to a
210+
specific number or variety of servers.
211+
| To learn more, see :manual:`Write Concern
212+
</reference/write-concern>` in the Server manual.
189213

190214
* - **wTimeoutMS**
191215
- Non-negative integer
192216
- No timeout
193217
- Specifies a time limit, in milliseconds, for the write concern.
194-
If an operation has not propagated to the requested level within the time limit, the driver raises an error.
218+
If an operation has not propagated to the requested level within
219+
the time limit, the driver raises an error.
195220

196221
* - **zlibCompressionLevel**
197222
- Integer between -1 and 9 (inclusive)
198223
- ``-1``
199-
- Specifies the level field of the ``zlib`` compression if you use that compressor.
200-
Setting a value of``-1`` selects the default compression level (``6``).
201-
Setting a value of ``0`` specifies no compression, and setting a value of ``9`` specifies maximum
202-
compression.
203-
To learn more about network compression, see the :ref:`rust-network-compression` guide.
204-
205-
For a full list of options, see the `ClientOptions API documentation <{+api+}/options/struct.ClientOptions.html>`__.
224+
- | Specifies the level field of the ``zlib`` compression if you use that compressor.
225+
| Setting a value of``-1`` selects the default compression level (``6``).
226+
| Setting a value of ``0`` specifies no compression, and setting
227+
a value of ``9`` specifies maximum compression.
228+
| To learn more about network compression, see the :ref:`rust-network-compression` guide.
229+
230+
To see a full list of connection options, visit the :manual:`Connection String
231+
Options section </reference/connection-string/#connection-string-options>` of the
232+
Server manual entry on Connection Strings.

source/quick-start/connect-to-mongodb.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ Connect to MongoDB
2020
.. tab:: Asynchronous API
2121
:tabid: asynchronous-api
2222

23-
.. literalinclude:: /code-snippets/quick-start/connect-async.rs
23+
.. literalinclude:: /includes/quick-start/code-snippets/connect-async.rs
2424
:language: rust
2525

2626
.. tab:: Synchronous API
2727
:tabid: synchronous-api
2828

29-
.. literalinclude:: /code-snippets/quick-start/connect-sync.rs
29+
.. literalinclude:: /includes/quick-start/code-snippets/connect-sync.rs
3030
:language: rust
3131

3232
.. step:: Assign the Connection String

0 commit comments

Comments
 (0)