Represent MongoClient's configuration. Take a list of (host, port) pairs and optional replica set name.
(
self,
seeds: Optional[Collection[tuple[str, int]]] = None,
replica_set_name: Optional[str] = None,
pool_class: Optional[Type[Pool]] = None,
pool_options: Optional[PoolOptions] = None,
monitor_class: Optional[Type[monitor.Monitor]] = None,
condition_class: Optional[Type[threading.Condition]] = None,
local_threshold_ms: int = LOCAL_THRESHOLD_MS,
server_selection_timeout: int = SERVER_SELECTION_TIMEOUT,
heartbeat_frequency: int = common.HEARTBEAT_FREQUENCY,
server_selector: Optional[_ServerSelector] = None,
fqdn: Optional[str] = None,
direct_connection: Optional[bool] = False,
load_balanced: Optional[bool] = None,
srv_service_name: str = common.SRV_SERVICE_NAME,
srv_max_hosts: int = 0,
server_monitoring_mode: str = common.SERVER_MONITORING_MODE,
topology_id: Optional[ObjectId] = None,
)
| 34 | |
| 35 | class TopologySettings: |
| 36 | def __init__( |
| 37 | self, |
| 38 | seeds: Optional[Collection[tuple[str, int]]] = None, |
| 39 | replica_set_name: Optional[str] = None, |
| 40 | pool_class: Optional[Type[Pool]] = None, |
| 41 | pool_options: Optional[PoolOptions] = None, |
| 42 | monitor_class: Optional[Type[monitor.Monitor]] = None, |
| 43 | condition_class: Optional[Type[threading.Condition]] = None, |
| 44 | local_threshold_ms: int = LOCAL_THRESHOLD_MS, |
| 45 | server_selection_timeout: int = SERVER_SELECTION_TIMEOUT, |
| 46 | heartbeat_frequency: int = common.HEARTBEAT_FREQUENCY, |
| 47 | server_selector: Optional[_ServerSelector] = None, |
| 48 | fqdn: Optional[str] = None, |
| 49 | direct_connection: Optional[bool] = False, |
| 50 | load_balanced: Optional[bool] = None, |
| 51 | srv_service_name: str = common.SRV_SERVICE_NAME, |
| 52 | srv_max_hosts: int = 0, |
| 53 | server_monitoring_mode: str = common.SERVER_MONITORING_MODE, |
| 54 | topology_id: Optional[ObjectId] = None, |
| 55 | ): |
| 56 | """Represent MongoClient's configuration. |
| 57 | |
| 58 | Take a list of (host, port) pairs and optional replica set name. |
| 59 | """ |
| 60 | if heartbeat_frequency < common.MIN_HEARTBEAT_INTERVAL: |
| 61 | raise ConfigurationError( |
| 62 | "heartbeatFrequencyMS cannot be less than %d" |
| 63 | % (common.MIN_HEARTBEAT_INTERVAL * 1000,) |
| 64 | ) |
| 65 | |
| 66 | self._seeds: Collection[tuple[str, int]] = seeds or [("localhost", 27017)] |
| 67 | self._replica_set_name = replica_set_name |
| 68 | self._pool_class: Type[Pool] = pool_class or pool.Pool |
| 69 | self._pool_options: PoolOptions = pool_options or PoolOptions() |
| 70 | self._monitor_class: Type[monitor.Monitor] = monitor_class or monitor.Monitor |
| 71 | self._condition_class: Type[threading.Condition] = condition_class or threading.Condition |
| 72 | self._local_threshold_ms = local_threshold_ms |
| 73 | self._server_selection_timeout = server_selection_timeout |
| 74 | self._server_selector = server_selector |
| 75 | self._fqdn = fqdn |
| 76 | self._heartbeat_frequency = heartbeat_frequency |
| 77 | self._direct = direct_connection |
| 78 | self._load_balanced = load_balanced |
| 79 | self._srv_service_name = srv_service_name |
| 80 | self._srv_max_hosts = srv_max_hosts or 0 |
| 81 | self._server_monitoring_mode = server_monitoring_mode |
| 82 | if topology_id is not None: |
| 83 | self._topology_id = topology_id |
| 84 | else: |
| 85 | self._topology_id = ObjectId() |
| 86 | # Store the allocation traceback to catch unclosed clients in the |
| 87 | # test suite. |
| 88 | self._stack = "".join(traceback.format_stack()[:-2]) |
| 89 | |
| 90 | @property |
| 91 | def seeds(self) -> Collection[tuple[str, int]]: |
nothing calls this directly
no test coverage detected