Skip to content

Commit eaf0e6d

Browse files
authored
PYTHON-3445 Improve documentation for custom readPreference tags (#1068)
1 parent 774154e commit eaf0e6d

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ For issues with, questions about, or feedback for PyMongo, please look into
2525
our `support channels <https://support.mongodb.com/welcome>`_. Please
2626
do not email any of the PyMongo developers directly with issues or
2727
questions - you're more likely to get an answer on the `MongoDB Community
28-
Forums <https://developer.mongodb.com/community/forums/tag/python-driver>`_.
28+
Forums <https://www.mongodb.com/community/forums/tag/python>`_.
2929

3030
Bugs / Feature Requests
3131
=======================

RELEASE.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ Doing a Release
8484
13. Publish the release version in Jira.
8585

8686
14. Announce the release on:
87-
https://developer.mongodb.com/community/forums/c/community/release-notes/
87+
https://www.mongodb.com/community/forums/c/announcements/driver-releases/110
8888

8989
15. File a ticket for DOCSP highlighting changes in server version and Python
9090
version compatibility or the lack thereof, for example:

pymongo/read_preferences.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,13 @@ def tag_sets(self) -> _TagSets:
151151
set, ``{}``, means "read from any member that matches the mode,
152152
ignoring tags." MongoClient tries each set of tags in turn
153153
until it finds a set of tags with at least one matching member.
154+
For example, to only send a query to an analytic node::
155+
156+
Nearest(tag_sets=[{"node":"analytics"}])
157+
158+
Or using :class:`SecondaryPreferred`::
159+
160+
SecondaryPreferred(tag_sets=[{"node":"analytics"}])
154161
155162
.. seealso:: `Data-Center Awareness
156163
<https://www.mongodb.com/docs/manual/data-center-awareness/>`_
@@ -518,7 +525,11 @@ def make_read_preference(
518525

519526

520527
class ReadPreference(object):
521-
"""An enum that defines the read preference modes supported by PyMongo.
528+
"""An enum that defines some commonly used read preference modes.
529+
530+
Apps can also create a custom read preference, for example::
531+
532+
Nearest(tag_sets=[{"node":"analytics"}])
522533
523534
See :doc:`/examples/high_availability` for code examples.
524535

0 commit comments

Comments
 (0)