topology_description – An object representation of a deployment of MongoDB servers. (original) (raw)

View this page

Toggle table of contents sidebar

Represent a deployment of MongoDB servers.

See also

This module is compatible with both the synchronous and asynchronous PyMongo APIs.

class pymongo.topology_description.TopologyDescription

Representation of a deployment of MongoDB servers.

Parameters:

apply_selector(selector, address=None, custom_selector=None)

List of servers matching the provided selector(s).

Parameters:

Return type:

list[ServerDescription]

Added in version 3.4.

check_compatible()

Raise ConfigurationError if any server is incompatible.

A server is incompatible if its wire protocol version range does not overlap with PyMongo’s.

Return type:

None

property common_wire_version_: int | None_

Minimum of all servers’ max wire versions, or None.

property has_known_servers_: bool_

Whether there are any Servers of types besides Unknown.

has_readable_server(read_preference=Primary())

Does this topology have any readable servers available matching the given read preference?

Parameters:

read_preference (_ServerMode) – an instance of a read preference fromread_preferences. Defaults toPRIMARY.

Return type:

bool

Note

When connected directly to a single server this method always returns True.

Added in version 3.4.

has_writable_server()

Does this topology have a writable server available?

Note

When connected directly to a single server this method always returns True.

Added in version 3.4.

Return type:

bool

property known_servers_: list[ServerDescription]_

List of Servers of types besides Unknown.

property logical_session_timeout_minutes_: int | None_

Minimum logical session timeout, or None.

property max_election_id_: ObjectId | None_

Greatest electionId seen from a primary, or None.

property max_set_version_: int | None_

Greatest setVersion seen from a primary, or None.

property readable_servers_: list[ServerDescription]_

List of readable Servers.

property replica_set_name_: str | None_

The replica set name.

reset()

A copy of this description, with all servers marked Unknown.

Return type:

TopologyDescription

reset_server(address)

A copy of this description, with one server marked Unknown.

Parameters:

address (Tuple[_str,_ int | None ])

Return type:

TopologyDescription

server_descriptions()

dict of (address,ServerDescription).

Return type:

dict[Tuple[str, int | None], ServerDescription]

property topology_type_: int_

The type of this topology.

property topology_type_name_: str_

The topology type as a human readable string.

Added in version 3.4.