topology_description
– An object representation of a deployment of MongoDB servers.#
Represent a deployment of MongoDB servers.
- class pymongo.topology_description.TopologyDescription#
Representation of a deployment of MongoDB servers.
- Parameters:
topology_type: initial type
server_descriptions: dict of (address, ServerDescription) for all seeds
replica_set_name: replica set name or None
max_set_version: greatest setVersion seen from a primary, or None
max_election_id: greatest electionId seen from a primary, or None
topology_settings: a TopologySettings
- apply_selector(selector: Any, address: Tuple[str, int | None] | None = None, custom_selector: Callable[[List[ServerDescription]], List[ServerDescription]] | None = None) List[ServerDescription] #
List of servers matching the provided selector(s).
- Parameters:
selector: a callable that takes a Selection as input and returns a Selection as output. For example, an instance of a read preference from
read_preferences
.address (optional): A server address to select.
custom_selector (optional): A callable that augments server selection rules. Accepts a list of
ServerDescription
objects and return a list of server descriptions that should be considered suitable for the desired operation.
New in version 3.4.
- check_compatible() None #
Raise ConfigurationError if any server is incompatible.
A server is incompatible if its wire protocol version range does not overlap with PyMongo’s.
- has_readable_server(read_preference: _ServerMode = Primary()) bool #
Does this topology have any readable servers available matching the given read preference?
- Parameters:
read_preference: an instance of a read preference from
read_preferences
. Defaults toPRIMARY
.
Note
When connected directly to a single server this method always returns
True
.New in version 3.4.
- has_writable_server() bool #
Does this topology have a writable server available?
Note
When connected directly to a single server this method always returns
True
.New in version 3.4.
- property known_servers: List[ServerDescription]#
List of Servers of types besides Unknown.
- property readable_servers: List[ServerDescription]#
List of readable Servers.
- reset() TopologyDescription #
A copy of this description, with all servers marked Unknown.
- reset_server(address: Tuple[str, int | None]) TopologyDescription #
A copy of this description, with one server marked Unknown.
- server_descriptions() Dict[Tuple[str, int | None], ServerDescription] #
Dict of (address,
ServerDescription
).