Skip to content

Commit 110ae03

Browse files
committed
add intro sentences
1 parent b4727a5 commit 110ae03

File tree

2 files changed

+54
-38
lines changed

2 files changed

+54
-38
lines changed

source/connect.txt

Lines changed: 28 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -78,24 +78,20 @@ instance of MongoDB:
7878
Atlas
7979
~~~~~
8080

81-
.. code-block:: kotlin
81+
The following code shows the connection string to connect to a
82+
deployment hosted on Atlas.
8283

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
9385

94-
val mongoClient = MongoClient.create(settings)
86+
val uri = "mongodb+srv://<username>:<password>@<hostname/port>/?<options>"
87+
val mongoClient = MongoClient.create(uri)
9588

9689
Replica Set
9790
~~~~~~~~~~~
9891

92+
The following code shows the connection string to connect to a
93+
replica set.
94+
9995
.. code-block:: kotlin
10096

10197
val uri = "mongodb://<replica set member>:<port>/?replicaSet=<replica set name>"
@@ -110,6 +106,8 @@ while enabling the TLS protocol.
110106
Enable TLS
111107
~~~~~~~~~~
112108

109+
The following tabs demonstrate how to enable TLS on a connection:
110+
113111
.. include:: /includes/connect/tls-tabs.rst
114112

115113
.. To learn more about enabling TLS, see :ref:`kotlin-sync-enable-tls` in
@@ -118,6 +116,9 @@ Enable TLS
118116
Disable Hostname Verification
119117
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
120118

119+
The following tabs demonstrate how to disable hostname verification when
120+
connecting by using TLS:
121+
121122
.. include:: /includes/connect/disable-host-verification-tabs.rst
122123

123124
.. To learn more about disabling hostname verification, see :ref:`kotlin-sync-insecure-tls` in
@@ -126,9 +127,15 @@ Disable Hostname Verification
126127
Network Compression
127128
-------------------
128129

130+
The following sections describe how to connect to MongoDB
131+
while specifying network compression algorithms.
132+
129133
Compression Algorithms
130134
~~~~~~~~~~~~~~~~~~~~~~
131135

136+
The following tabs demonstrate how to specify all available compressors
137+
while connecting to MongoDB:
138+
132139
.. include:: /includes/connect/compression-tabs.rst
133140

134141
.. To learn more about specifying compression algorithms, see
@@ -137,39 +144,20 @@ Compression Algorithms
137144
zlib Compression Level
138145
~~~~~~~~~~~~~~~~~~~~~~
139146

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:
148149

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
166151

167152
.. To learn more about setting the zlib compression level, see
168153
.. :ref:`kotlin-sync-enable-compression` in the Network Compression guide.
169154

170155
Server Selection
171156
----------------
172157

158+
The following code shows a connection string that specifies a server
159+
selection function:
160+
173161
.. code-block:: kotlin
174162

175163
val client = MongoClient.create("mongodb://<username>:<password>@<hostname>:<port>",
@@ -181,6 +169,9 @@ Server Selection
181169
{+stable-api+}
182170
--------------
183171

172+
The following code shows how to specify Stable API settings within a
173+
``MongoClientSettings`` instance:
174+
184175
.. code-block:: kotlin
185176

186177
val serverApi = ServerApi.builder()
@@ -196,5 +187,4 @@ Server Selection
196187

197188
val client = MongoClient.create(settings)
198189

199-
200190
.. To learn more about the {+stable-api+}, see :ref:`kotlin-sync-stable-api`.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
.. tabs::
2+
3+
.. tab:: MongoClient
4+
:tabid: mongoclient
5+
6+
.. code-block:: kotlin
7+
8+
val zlib = MongoCompressor.createZlibCompressor()
9+
10+
val settings = MongoClientSettings.builder()
11+
.applyConnectionString(ConnectionString(uri))
12+
.compressorList(listOf(zlib.withProperty(MongoCompressor.LEVEL, <level>)))
13+
.build()
14+
15+
val mongoClient = MongoClient.create(settings)
16+
17+
.. tab:: Connection String
18+
:tabid: connectionstring
19+
20+
.. code-block:: kotlin
21+
22+
val uri = "mongodb://<username>:<password>@<hostname>:<port>/?" +
23+
"compressors=zlib" +
24+
"zlibCompressionLevel=<zlib compression level>"
25+
26+
val mongoClient = MongoClient.create(uri)

0 commit comments

Comments
 (0)