@@ -78,24 +78,20 @@ instance of MongoDB:
78
78
Atlas
79
79
~~~~~
80
80
81
- .. code-block:: kotlin
81
+ The following code shows the connection string to connect to a
82
+ deployment hosted on Atlas.
82
83
83
- val uri = "<Atlas connection string>"
84
-
85
- val serverApi = ServerApi.builder()
86
- .version(ServerApiVersion.V1)
87
- .build()
88
-
89
- val settings = MongoClientSettings.builder()
90
- .applyConnectionString(ConnectionString(uri))
91
- .serverApi(serverApi)
92
- .build()
84
+ .. code-block:: kotlin
93
85
94
- val mongoClient = MongoClient.create(settings)
86
+ val uri = "mongodb+srv://<username>:<password>@<hostname/port>/?<options>"
87
+ val mongoClient = MongoClient.create(uri)
95
88
96
89
Replica Set
97
90
~~~~~~~~~~~
98
91
92
+ The following code shows the connection string to connect to a
93
+ replica set.
94
+
99
95
.. code-block:: kotlin
100
96
101
97
val uri = "mongodb://<replica set member>:<port>/?replicaSet=<replica set name>"
@@ -110,6 +106,8 @@ while enabling the TLS protocol.
110
106
Enable TLS
111
107
~~~~~~~~~~
112
108
109
+ The following tabs demonstrate how to enable TLS on a connection:
110
+
113
111
.. include:: /includes/connect/tls-tabs.rst
114
112
115
113
.. To learn more about enabling TLS, see :ref:`kotlin-sync-enable-tls` in
@@ -118,6 +116,9 @@ Enable TLS
118
116
Disable Hostname Verification
119
117
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
120
118
119
+ The following tabs demonstrate how to disable hostname verification when
120
+ connecting by using TLS:
121
+
121
122
.. include:: /includes/connect/disable-host-verification-tabs.rst
122
123
123
124
.. To learn more about disabling hostname verification, see :ref:`kotlin-sync-insecure-tls` in
@@ -126,9 +127,15 @@ Disable Hostname Verification
126
127
Network Compression
127
128
-------------------
128
129
130
+ The following sections describe how to connect to MongoDB
131
+ while specifying network compression algorithms.
132
+
129
133
Compression Algorithms
130
134
~~~~~~~~~~~~~~~~~~~~~~
131
135
136
+ The following tabs demonstrate how to specify all available compressors
137
+ while connecting to MongoDB:
138
+
132
139
.. include:: /includes/connect/compression-tabs.rst
133
140
134
141
.. To learn more about specifying compression algorithms, see
@@ -137,39 +144,20 @@ Compression Algorithms
137
144
zlib Compression Level
138
145
~~~~~~~~~~~~~~~~~~~~~~
139
146
140
- .. tabs::
141
-
142
- .. tab:: MongoClient
143
- :tabid: mongoclient
144
-
145
- .. code-block:: kotlin
146
-
147
- val zlib = MongoCompressor.createZlibCompressor()
147
+ The following tabs demonstrate how to specify a compression level for
148
+ the ``zlib`` compressor:
148
149
149
- val settings = MongoClientSettings.builder()
150
- .applyConnectionString(ConnectionString(uri))
151
- .compressorList(listOf(zlib.withProperty(MongoCompressor.LEVEL, <level>)))
152
- .build()
153
-
154
- val mongoClient = MongoClient.create(settings)
155
-
156
- .. tab:: Connection String
157
- :tabid: connectionstring
158
-
159
- .. code-block:: kotlin
160
-
161
- val uri = "mongodb://<username>:<password>@<hostname>:<port>/?" +
162
- "compressors=zlib" +
163
- "zlibCompressionLevel=<zlib compression level>"
164
-
165
- val mongoClient = MongoClient.create(uri)
150
+ .. include:: /includes/connect/zlib-level-tabs.rst
166
151
167
152
.. To learn more about setting the zlib compression level, see
168
153
.. :ref:`kotlin-sync-enable-compression` in the Network Compression guide.
169
154
170
155
Server Selection
171
156
----------------
172
157
158
+ The following code shows a connection string that specifies a server
159
+ selection function:
160
+
173
161
.. code-block:: kotlin
174
162
175
163
val client = MongoClient.create("mongodb://<username>:<password>@<hostname>:<port>",
@@ -181,6 +169,9 @@ Server Selection
181
169
{+stable-api+}
182
170
--------------
183
171
172
+ The following code shows how to specify Stable API settings within a
173
+ ``MongoClientSettings`` instance:
174
+
184
175
.. code-block:: kotlin
185
176
186
177
val serverApi = ServerApi.builder()
@@ -196,5 +187,4 @@ Server Selection
196
187
197
188
val client = MongoClient.create(settings)
198
189
199
-
200
190
.. To learn more about the {+stable-api+}, see :ref:`kotlin-sync-stable-api`.
0 commit comments