Skip to content

Commit 37795d9

Browse files
authored
DOCSP-26508 Add --forceConnectionOptions (#465)
* DOCSP-26508 Add --forceConnectionOptions * edit task page + fix table proportions * edit toc * fix reflink * update include description * another reflink fix * cleanup include description * add reasoning in task page desc * DC edits * typo * DC feedback * AH feedback * build errors * clean up intro text * clean up sentence pt 2
1 parent 1081a74 commit 37795d9

File tree

5 files changed

+110
-9
lines changed

5 files changed

+110
-9
lines changed

source/command-line-options.txt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ cannot be set in the :guilabel:`Settings` panel.
7373

7474
Show |compass| version.
7575

76-
Command Line or Settings Panel
77-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
76+
General Settings
77+
~~~~~~~~~~~~~~~~
7878

79-
These options can be set on the command line **or** in the
80-
:guilabel:`Settings` panel. Setting an option on the command line
81-
overrides the value in the :guilabel:`Settings` panel.
79+
These options can be set on the command line, in a configuration file, or in the
80+
:guilabel:`Settings` panel. Setting an option on the command line overrides the
81+
value in the :guilabel:`Settings` panel.
8282

8383
.. option:: --autoUpdates
8484

@@ -95,6 +95,10 @@ overrides the value in the :guilabel:`Settings` panel.
9595
Allow |compass| to make requests to a 3rd party mapping service. Use
9696
``--no-enableMaps`` to disable mapping requests.
9797

98+
.. option:: --forceConnectionOptions
99+
100+
.. include:: /includes/fact-force-connection-options.rst
101+
98102
.. option:: --networkTraffic
99103

100104
Configure |compass| to only allow outgoing :ref:`network operations

source/config-file.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,17 @@ When you configure settings with a configuration file:
5757
Tasks
5858
-----
5959

60-
To see how to configure specific settings, see :ref:`Compass Configuration File Options
61-
<config-file-options>`.
60+
- :ref:`compass-configure-network-traffic`
61+
62+
- :ref:`specify-read-preference-tags`
63+
64+
.. seealso::
65+
66+
:ref:`<config-file-options>`
6267

6368
.. toctree::
6469
:titlesonly:
6570

66-
/config-file/restrict-outgoing-connections
6771
/config-file/config-file-options
72+
/config-file/restrict-outgoing-connections
73+
/config-file/specify-read-preference-tags

source/config-file/config-file-options.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,14 @@ You can configure the following settings in a configuration file:
5050

5151
.. list-table::
5252
:header-rows: 1
53-
:widths: 15 60
53+
:widths: 30 70
5454

5555
* - Setting
5656
- Definition
5757

58+
* - :ref:`forceConnectionOptions <compass-force-connection-options>`
59+
- .. include:: /includes/fact-force-connection-options.rst
60+
5861
* - :ref:`networkTraffic <compass-configure-network-traffic>`
5962
- Configure |compass| to not perform outgoing network operations other
6063
than those to the database.
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
.. _compass-force-connection-options:
2+
.. _specify-read-preference-tags:
3+
4+
================================
5+
Specify Read Preference and Tags
6+
================================
7+
8+
.. default-domain:: mongodb
9+
10+
.. contents:: On this page
11+
:local:
12+
:backlinks: none
13+
:depth: 2
14+
:class: singlecol
15+
16+
You can use the ``forceConnectionOptions`` option to set required connection
17+
option values on |compass-short|. By setting required connection options such as
18+
read preference, you can restrict how users connect to your MongoDB deployment
19+
and ensure that their read operations don't impact the availability of replica
20+
set primaries.
21+
22+
Procedure
23+
---------
24+
25+
In this example, you limit read operations to read only from ``SECONDARY``
26+
replica set members with the ``ANALYTICS`` and ``READ_ONLY`` tags. You can
27+
specify these options on the command line or in a :ref:`configuration
28+
file <config-file>`.
29+
30+
Command Line Example
31+
~~~~~~~~~~~~~~~~~~~~
32+
33+
The following command starts |compass| from the command line and uses
34+
``--forceConnectionOptions`` to set the ``readPreference`` and
35+
``readPreferenceTags`` options:
36+
37+
.. code-block:: sh
38+
39+
<path-to-Compass-executable> \
40+
--forceConnectionOptions.readPreference=secondary \
41+
--forceConnectionOptions.readPreferenceTags=nodeType:ANALYTICS \
42+
--forceConnectionOptions.readPreferenceTags=nodeType:READ_ONLY
43+
44+
.. note::
45+
46+
The name and filepath of the |compass-short| executable depend on your
47+
operating system.
48+
49+
Configuration File Example
50+
~~~~~~~~~~~~~~~~~~~~~~~~~~
51+
52+
You can specify the |compass-short| configuration file in either EJSON
53+
or YAML format. To set the ``readPreference`` and ``readPreferenceTags``, use
54+
``--forceConnectionOptions``:
55+
56+
EJSON
57+
`````
58+
59+
.. code-block:: json
60+
61+
{
62+
"forceConnectionOptions": [
63+
["readPreference", "secondary"],
64+
["readPreferenceTags", "nodeType:ANALYTICS"],
65+
["readPreferenceTags", "nodeType:READ_ONLY"]
66+
]
67+
}
68+
69+
YAML
70+
````
71+
72+
.. code-block:: yaml
73+
74+
forceConnectionOptions:
75+
- readPreference: secondary
76+
- readPreferenceTags: nodeType:ANALYTICS
77+
- readPreferenceTags: nodeType:READ_ONLY
78+
79+
Learn More
80+
----------
81+
82+
To learn more about the |compass| configuration file, see
83+
:ref:`config-file`.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Assign :manual:`connection option
2+
</reference/connection-string/#connection-string-options>` values for when you
3+
connect to your MongoDB deployment through |compass-short|. These connection
4+
options cannot be overridden by connections from the |compass-short| interface or
5+
a command line connection string.

0 commit comments

Comments
 (0)