Parse connection pool options.
(
username: str,
password: str,
database: Optional[str],
options: Mapping[str, Any],
is_sync: bool,
)
| 147 | |
| 148 | |
| 149 | def _parse_pool_options( |
| 150 | username: str, |
| 151 | password: str, |
| 152 | database: Optional[str], |
| 153 | options: Mapping[str, Any], |
| 154 | is_sync: bool, |
| 155 | ) -> PoolOptions: |
| 156 | """Parse connection pool options.""" |
| 157 | credentials = _parse_credentials(username, password, database, options) |
| 158 | max_pool_size = options.get("maxpoolsize", common.MAX_POOL_SIZE) |
| 159 | min_pool_size = options.get("minpoolsize", common.MIN_POOL_SIZE) |
| 160 | max_idle_time_seconds = options.get("maxidletimems", common.MAX_IDLE_TIME_SEC) |
| 161 | if max_pool_size is not None and min_pool_size > max_pool_size: |
| 162 | raise ValueError("minPoolSize must be smaller or equal to maxPoolSize") |
| 163 | connect_timeout = options.get("connecttimeoutms", common.CONNECT_TIMEOUT) |
| 164 | socket_timeout = options.get("sockettimeoutms") |
| 165 | wait_queue_timeout = options.get("waitqueuetimeoutms", common.WAIT_QUEUE_TIMEOUT) |
| 166 | event_listeners = cast(Optional[Sequence[_EventListener]], options.get("event_listeners")) |
| 167 | appname = options.get("appname") |
| 168 | driver = options.get("driver") |
| 169 | server_api = options.get("server_api") |
| 170 | compression_settings = CompressionSettings( |
| 171 | options.get("compressors", []), options.get("zlibcompressionlevel", -1) |
| 172 | ) |
| 173 | ssl_context, tls_allow_invalid_hostnames = _parse_ssl_options(options, is_sync) |
| 174 | load_balanced = options.get("loadbalanced") |
| 175 | max_connecting = options.get("maxconnecting", common.MAX_CONNECTING) |
| 176 | return PoolOptions( |
| 177 | max_pool_size, |
| 178 | min_pool_size, |
| 179 | max_idle_time_seconds, |
| 180 | connect_timeout, |
| 181 | socket_timeout, |
| 182 | wait_queue_timeout, |
| 183 | ssl_context, |
| 184 | tls_allow_invalid_hostnames, |
| 185 | _EventListeners(event_listeners), |
| 186 | appname, |
| 187 | driver, |
| 188 | compression_settings, |
| 189 | max_connecting=max_connecting, |
| 190 | server_api=server_api, |
| 191 | load_balanced=load_balanced, |
| 192 | credentials=credentials, |
| 193 | is_sync=is_sync, |
| 194 | ) |
| 195 | |
| 196 | |
| 197 | class ClientOptions: |
no test coverage detected