File tree Expand file tree Collapse file tree 3 files changed +9
-8
lines changed
connect/connection-options Expand file tree Collapse file tree 3 files changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ Specify Settings
2727----------------
2828
2929You can specify settings for your clusters by using either a connection string
30- or by using the ``ClientOptions`` struct when creating a new ``Client``
30+ or a ``ClientOptions`` struct when creating a new ``Client``
3131instance. Select the :guilabel:`Connection String` or :guilabel:`ClientOptions` tab to see the
3232available options.
3333
@@ -36,8 +36,9 @@ available options.
3636 .. tab:: Connection String
3737 :tabid: uri
3838
39- You can use the following parameters in your connection string to modify the
40- driver's behavior when interacting with your MongoDB cluster:
39+ The following table describes the parameters you can use in your connection
40+ string to modify the driver's behavior when interacting with your MongoDB
41+ cluster:
4142
4243 .. list-table::
4344 :header-rows: 1
@@ -79,7 +80,7 @@ available options.
7980 construct your :manual:`seed list
8081 </reference/glossary/#std-term-seed-list>`. You must use the
8182 :manual:`DNS Seed List Connection Format
82- </reference/connection-string/#dns-seed -list-connection-format>` in
83+ </reference/connection-string/#srv -list-connection-format>` in
8384 your connection string to use this option.
8485
8586 .. tab:: ClientOptions
Original file line number Diff line number Diff line change @@ -15,14 +15,14 @@ func main() {
1515 if uri == "" {
1616 log .Fatal ("Set your 'MONGODB_URI' environment variable." )
1717 }
18- // start-client-options
18+
1919 // Sets client options with cluster settings
20+ // start-client-options
2021 clientOptions := options .Client ().
2122 ApplyURI (uri ).
2223 SetServerSelectionTimeout (10 * time .Second ).
2324 SetLocalThreshold (20 * time .Millisecond )
2425
25- // Creates a new client and connects to the server
2626 client , err := mongo .Connect (clientOptions )
2727 if err != nil {
2828 log .Fatal (err )
Original file line number Diff line number Diff line change @@ -9,17 +9,17 @@ import (
99 "go.mongodb.org/mongo-driver/v2/mongo/options"
1010)
1111
12- // start-uri-variable
1312// Connection string with cluster settings options
13+ // start-uri-variable
1414const (
1515 uri = "mongodb://localhost:27017/?serverSelectionTimeoutMS=10000&localThresholdMS=20"
1616)
1717
1818// end-uri-variable
1919
2020func main () {
21- // start-apply-uri
2221 // Creates a new client and connects to the server
22+ // start-apply-uri
2323 client , err := mongo .Connect (options .Client ().ApplyURI (uri ))
2424 if err != nil {
2525 log .Fatal (err )
You can’t perform that action at this time.
0 commit comments