@@ -57,7 +57,7 @@ A standard connection string includes the following components:
57
57
- Optional. Authentication credentials. If you include these, the client
58
58
authenticates the user against the database specified in ``authSource``.
59
59
For more information about the ``authSource`` connection option,
60
- see :ref:`golang-connection-troubleshooting` in the Connection Troubleshooting guide.
60
+ see the :ref:`golang-connection-troubleshooting` guide.
61
61
62
62
* - ``host[:port]``
63
63
@@ -79,6 +79,11 @@ A standard connection string includes the following components:
79
79
:ref:`golang-connection-options` for a full description of
80
80
these options.
81
81
82
+ .. tip::
83
+
84
+ To retrieve a connection string for an Atlas deployment, follow the
85
+ :ref:`Quick Start guide <golang-connect-to-your-cluster>`.
86
+
82
87
For more information about creating a connection string, see :manual:`Connection
83
88
Strings </reference/connection-string>` in the MongoDB Server documentation.
84
89
@@ -95,14 +100,14 @@ To specify your connection URI, pass it to the ``ApplyURI()`` method, which
95
100
returns a new ``ClientOptions`` instance. To set any other options, call the
96
101
relevant helper method from the options package.
97
102
98
- .. tip:: Reuse Your Client
103
+ .. tip:: Reuse Your Client with Connection Pools
99
104
100
- We recommend that you reuse your client across sessions and operations. You
101
- can use the same ``Client`` instance to perform multiple tasks, instead of
102
- creating a new one each time. The ``Client`` type is safe for concurrent use
103
- by multiple `goroutines <https://go.dev/tour/concurrency/1>`__. To learn more
104
- about how connection pools work in the driver, see the
105
- :ref:`golang-connection-pools` guide.
105
+ We recommend that you reuse your client across sessions and operations by
106
+ using a connection pool. You can use the same ``Client`` instance to perform
107
+ multiple tasks, instead of creating a new one each time. The ``Client`` type
108
+ is safe for concurrent use by multiple `goroutines
109
+ <https://go.dev/tour/concurrency/1>`__. To learn more about how connection
110
+ pools work in the driver, see the :ref:`golang-connection-pools` guide.
106
111
107
112
To learn more about connection options, see the :ref:`Connection Options
108
113
<golang-connection-options>` section. To learn more about creating a client, see
@@ -127,77 +132,24 @@ that the connection is successful:
127
132
:copyable:
128
133
:dedent:
129
134
130
- .. tip::
131
-
132
- Follow the :ref:`Quick Start guide <golang-connect-to-your-cluster>`
133
- to learn how to retrieve your Atlas connection string.
134
-
135
- .. note::
136
-
137
- To learn about connecting to Atlas Serverless, see the
138
- :ref:`Serverless Instance Limitations page
139
- <atlas-serverless-drivers>` to identify the minimum driver version
140
- required.
141
-
142
- Other Ways to Connect to MongoDB
143
- --------------------------------
144
-
145
- If you are connecting to a single MongoDB server instance or replica set
146
- that is not hosted on Atlas, see the following sections to learn how to
147
- connect.
148
-
149
- Connect to a MongoDB Server on Your Local Machine
150
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
151
-
152
- .. include:: /includes/localhost-connection.rst
153
-
154
- To test whether you can connect to your server, replace the connection string
155
- with your localhost connection string in the preceding `code example <go-connection-example-code>`.
156
-
157
- Connect to a Replica Set
158
- ~~~~~~~~~~~~~~~~~~~~~~~~
159
-
160
- A MongoDB replica set deployment is a group of connected instances that
161
- store the same set of data. This configuration provides data
162
- redundancy and high data availability.
163
-
164
- To connect to a replica set deployment, specify the hostname and port numbers
165
- of each instance, separated by commas, and the replica set name as the value
166
- of the ``replicaSet`` parameter in the connection string. In the following
167
- example, the hostnames are ``host1``, ``host2``, and ``host3``, and the
168
- port numbers are all ``27017``. The replica set name is ``myRS``.
169
-
170
- .. code-block:: none
171
-
172
- mongodb://host1:27017,host2:27017,host3:27017/?replicaSet=myRS
173
-
174
- When connecting to a replica set, the driver takes the following actions by default:
175
-
176
- - Discovers all replica set members when given the address of any one member.
177
- - Dispatches operations to the appropriate member, such as instructions
178
- to write against the **primary**.
179
-
180
- .. tip::
181
-
182
- You can specify just one host to connect to a replica set.
183
- However, to ensure connectivity when the specified host
184
- is unavailable, you must provide the full list of hosts.
185
-
186
- To learn more about replication in MongoDB, see the :manual:`Replication </replication>` section of Server manual.
135
+ Additional Resources
136
+ --------------------
187
137
188
- Direct Connection
189
- `````````````````
138
+ For more information about the concepts in this guide, see the following
139
+ documentation:
190
140
191
- To force operations on the host designated in the connection URI,
192
- specify the ``directConnection`` option. Direct connections exhibit the
193
- following behavior:
141
+ - :manual:`Connection Strings </reference/connection-string>` in the Server
142
+ manual
143
+ - :manual:`Connection String Options </reference/connection-string>` in the
144
+ Server manual
145
+ - :atlas:`Connect via Drivers </driver-connection/>` in the Atlas documentation
146
+ and select :guilabel:`Go` from the language dropdown
194
147
195
- - They don't support SRV strings.
196
- - They fail on writes when the specified host is not the **primary**.
197
- - They require you to specify a :manual:`secondary read preference
198
- </core/read-preference/#mongodb-readmode-secondary>` when the
199
- specified host isn't the **primary** node.
148
+ API Documentation
149
+ ~~~~~~~~~~~~~~~~~
200
150
201
- .. note:: Replica Set in Docker
151
+ To learn more about the methods and types discussed in this guide, see the
152
+ following API Documentation:
202
153
203
- .. sharedinclude:: dbx/docker-replica-set.rst
154
+ - `Client <{+api+}/mongo#Client>`__
155
+ - `ClientOptions <{+api+}/options#ClientOptions>`__
0 commit comments