Configuration for limits to various client behaviors. **Parameters:** * **max_connections** - The maximum number of concurrent connections that may be established. * **max_keepalive_connections** - Allow the connection pool to maintain keep-alive connection
| 157 | |
| 158 | |
| 159 | class Limits: |
| 160 | """ |
| 161 | Configuration for limits to various client behaviors. |
| 162 | |
| 163 | **Parameters:** |
| 164 | |
| 165 | * **max_connections** - The maximum number of concurrent connections that may be |
| 166 | established. |
| 167 | * **max_keepalive_connections** - Allow the connection pool to maintain |
| 168 | keep-alive connections below this point. Should be less than or equal |
| 169 | to `max_connections`. |
| 170 | * **keepalive_expiry** - Time limit on idle keep-alive connections in seconds. |
| 171 | """ |
| 172 | |
| 173 | def __init__( |
| 174 | self, |
| 175 | *, |
| 176 | max_connections: int | None = None, |
| 177 | max_keepalive_connections: int | None = None, |
| 178 | keepalive_expiry: float | None = 5.0, |
| 179 | ) -> None: |
| 180 | self.max_connections = max_connections |
| 181 | self.max_keepalive_connections = max_keepalive_connections |
| 182 | self.keepalive_expiry = keepalive_expiry |
| 183 | |
| 184 | def __eq__(self, other: typing.Any) -> bool: |
| 185 | return ( |
| 186 | isinstance(other, self.__class__) |
| 187 | and self.max_connections == other.max_connections |
| 188 | and self.max_keepalive_connections == other.max_keepalive_connections |
| 189 | and self.keepalive_expiry == other.keepalive_expiry |
| 190 | ) |
| 191 | |
| 192 | def __repr__(self) -> str: |
| 193 | class_name = self.__class__.__name__ |
| 194 | return ( |
| 195 | f"{class_name}(max_connections={self.max_connections}, " |
| 196 | f"max_keepalive_connections={self.max_keepalive_connections}, " |
| 197 | f"keepalive_expiry={self.keepalive_expiry})" |
| 198 | ) |
| 199 | |
| 200 | |
| 201 | class Proxy: |