OpenQuizz
Une application de gestion des contenus pédagogiques
_ServerMode Class Reference
Inheritance diagram for _ServerMode:
Collaboration diagram for _ServerMode:

Public Member Functions

def __init__ (self, mode, tag_sets=None, max_staleness=-1, hedge=None)
 
def name (self)
 
def mongos_mode (self)
 
def document (self)
 
def mode (self)
 
def tag_sets (self)
 
def max_staleness (self)
 
def hedge (self)
 
def min_wire_version (self)
 
def __repr__ (self)
 
def __eq__ (self, other)
 
def __ne__ (self, other)
 
def __getstate__ (self)
 
def __setstate__ (self, value)
 

Data Fields

 mode
 
 tag_sets
 
 max_staleness
 
 hedge
 

Detailed Description

Base class for all read preferences.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  mode,
  tag_sets = None,
  max_staleness = -1,
  hedge = None 
)

Member Function Documentation

◆ __eq__()

def __eq__ (   self,
  other 
)

Reimplemented in Primary.

◆ __getstate__()

def __getstate__ (   self)
Return value of object for pickling.

Needed explicitly because __slots__() defined.

◆ __ne__()

def __ne__ (   self,
  other 
)

◆ __repr__()

def __repr__ (   self)

Reimplemented in Primary.

◆ __setstate__()

def __setstate__ (   self,
  value 
)
Restore from pickling.

◆ document()

def document (   self)
Read preference as a document.

◆ hedge()

def hedge (   self)
The read preference ``hedge`` parameter.

A dictionary that configures how the server will perform hedged reads.
It consists of the following keys:

- ``enabled``: Enables or disables hedged reads in sharded clusters.

Hedged reads are automatically enabled in MongoDB 4.4+ when using a
``nearest`` read preference. To explicitly enable hedged reads, set
the ``enabled`` key  to ``true``::

    >>> Nearest(hedge={'enabled': True})

To explicitly disable hedged reads, set the ``enabled`` key  to
``False``::

    >>> Nearest(hedge={'enabled': False})

.. versionadded:: 3.11

◆ max_staleness()

def max_staleness (   self)
The maximum estimated length of time (in seconds) a replica set
secondary can fall behind the primary in replication before it will
no longer be selected for operations, or -1 for no maximum.

◆ min_wire_version()

def min_wire_version (   self)
The wire protocol version the server must support.

Some read preferences impose version requirements on all servers (e.g.
maxStalenessSeconds requires MongoDB 3.4 / maxWireVersion 5).

All servers' maxWireVersion must be at least this read preference's
`min_wire_version`, or the driver raises
:exc:`~pymongo.errors.ConfigurationError`.

◆ mode()

def mode (   self)
The mode of this read preference instance.

◆ mongos_mode()

def mongos_mode (   self)
The mongos mode of this read preference.

◆ name()

def name (   self)
The name of this read preference.

◆ tag_sets()

def tag_sets (   self)
Set ``tag_sets`` to a list of dictionaries like [{'dc': 'ny'}] to
read only from members whose ``dc`` tag has the value ``"ny"``.
To specify a priority-order for tag sets, provide a list of
tag sets: ``[{'dc': 'ny'}, {'dc': 'la'}, {}]``. A final, empty tag
set, ``{}``, means "read from any member that matches the mode,
ignoring tags." MongoReplicaSetClient tries each set of tags in turn
until it finds a set of tags with at least one matching member.

   .. seealso:: `Data-Center Awareness
       <http://www.mongodb.org/display/DOCS/Data+Center+Awareness>`_

Field Documentation

◆ hedge

hedge

◆ max_staleness

max_staleness

◆ mode

mode

◆ tag_sets

tag_sets

The documentation for this class was generated from the following file: