def __call__(self, td): """Return matching ServerDescriptions from a TopologyDescription.""" writable_servers = writable_server_selector(td) if writable_servers: return writable_servers else: return secondary_with_tags_server_selector(self.tag_sets, td)
def __call__(self, td): """Return matching ServerDescriptions from a TopologyDescription.""" writable_servers = writable_server_selector(td) if writable_servers: return writable_servers else: return secondary_with_tags_server_selector(self.tag_sets, td)
def __call__(self, server_descriptions): """Return matching ServerDescriptions from a list.""" writable_servers = writable_server_selector(server_descriptions) if writable_servers: return writable_servers else: return secondary_with_tags_server_selector(self.tag_sets, server_descriptions)
def get_primary(self): """Return primary's address or None.""" # Implemented here in Topology instead of MongoClient, so it can lock. with self._lock: topology_type = self._description.topology_type if topology_type != TOPOLOGY_TYPE.ReplicaSetWithPrimary: return None return writable_server_selector(self._new_selection())[0].address
def get_primary(self): """Return primary's address or None.""" # Implemented here in Topology instead of MongoClient, so it can lock. with self._lock: topology_type = self._description.topology_type if topology_type != TOPOLOGY_TYPE.ReplicaSetWithPrimary: return None return writable_server_selector(self._new_selection())[0].address
def __call__(self, server_descriptions): """Return matching ServerDescriptions from a list.""" writable_servers = writable_server_selector(server_descriptions) if writable_servers: return writable_servers else: return secondary_with_tags_server_selector( self.tag_sets, server_descriptions)
def get_direct_or_primary(self): """Return the address of a connected primary or standalone, or None. Raise InvalidOperation for Sharded topologies. """ # Implemented here in Topology instead of MongoClient, so it can lock. with self._lock: topology_type = self._description.topology_type if topology_type == TOPOLOGY_TYPE.Sharded: raise InvalidOperation() if topology_type not in (TOPOLOGY_TYPE.ReplicaSetWithPrimary, TOPOLOGY_TYPE.Single): return None descriptions = writable_server_selector( self._description.known_servers) return descriptions[0].address if descriptions else None
def get_direct_or_primary(self): """Return the address of a connected primary or standalone, or None. Raise InvalidOperation for Sharded topologies. """ # Implemented here in Topology instead of MongoClient, so it can lock. with self._lock: topology_type = self._description.topology_type if topology_type == TOPOLOGY_TYPE.Sharded: raise InvalidOperation() if topology_type not in (TOPOLOGY_TYPE.ReplicaSetWithPrimary, TOPOLOGY_TYPE.Single): return None descriptions = writable_server_selector( self._description.known_servers) return descriptions[0].address if descriptions else None
def __call__(self, server_descriptions): """Return matching ServerDescriptions from a list.""" return writable_server_selector(server_descriptions)
def __call__(self, server_descriptions): """Return matching ServerDescriptions from a list.""" return writable_server_selector(server_descriptions)
def __call__(self, td): """Return matching ServerDescriptions from a TopologyDescription.""" return writable_server_selector(td)
def __call__(self, td): """Return matching ServerDescriptions from a TopologyDescription.""" return writable_server_selector(td)