Initialize a new async Connection. Parameters ---------- driver_info : DriverInfo, optional Driver metadata for CLIENT SETINFO. If provided, lib_name and lib_version are ignored. If not provided, a DriverInfo will be created from lib_name
(
self,
*,
db: str | int = 0,
password: str | None = None,
socket_timeout: float | None = DEFAULT_SOCKET_TIMEOUT,
socket_connect_timeout: float | None = DEFAULT_SOCKET_CONNECT_TIMEOUT,
retry_on_timeout: bool = False,
retry_on_error: list | object = SENTINEL,
encoding: str = "utf-8",
encoding_errors: str = "strict",
decode_responses: bool = False,
parser_class: Type[BaseParser] = DefaultParser,
socket_read_size: int = DEFAULT_SOCKET_READ_SIZE,
health_check_interval: float = 0,
client_name: str | None = None,
lib_name: str | object | None = SENTINEL,
lib_version: str | object | None = SENTINEL,
driver_info: DriverInfo | object | None = SENTINEL,
username: str | None = None,
retry: Retry | None = None,
redis_connect_func: ConnectCallbackT | None = None,
encoder_class: Type[Encoder] = Encoder,
credential_provider: CredentialProvider | None = None,
protocol: int | None = None,
legacy_responses: bool = True,
event_dispatcher: EventDispatcher | None = None,
)
| 163 | "lib_name and lib_version will be removed in a future version.", |
| 164 | ) |
| 165 | def __init__( |
| 166 | self, |
| 167 | *, |
| 168 | db: str | int = 0, |
| 169 | password: str | None = None, |
| 170 | socket_timeout: float | None = DEFAULT_SOCKET_TIMEOUT, |
| 171 | socket_connect_timeout: float | None = DEFAULT_SOCKET_CONNECT_TIMEOUT, |
| 172 | retry_on_timeout: bool = False, |
| 173 | retry_on_error: list | object = SENTINEL, |
| 174 | encoding: str = "utf-8", |
| 175 | encoding_errors: str = "strict", |
| 176 | decode_responses: bool = False, |
| 177 | parser_class: Type[BaseParser] = DefaultParser, |
| 178 | socket_read_size: int = DEFAULT_SOCKET_READ_SIZE, |
| 179 | health_check_interval: float = 0, |
| 180 | client_name: str | None = None, |
| 181 | lib_name: str | object | None = SENTINEL, |
| 182 | lib_version: str | object | None = SENTINEL, |
| 183 | driver_info: DriverInfo | object | None = SENTINEL, |
| 184 | username: str | None = None, |
| 185 | retry: Retry | None = None, |
| 186 | redis_connect_func: ConnectCallbackT | None = None, |
| 187 | encoder_class: Type[Encoder] = Encoder, |
| 188 | credential_provider: CredentialProvider | None = None, |
| 189 | protocol: int | None = None, |
| 190 | legacy_responses: bool = True, |
| 191 | event_dispatcher: EventDispatcher | None = None, |
| 192 | ): |
| 193 | """ |
| 194 | Initialize a new async Connection. |
| 195 | |
| 196 | Parameters |
| 197 | ---------- |
| 198 | driver_info : DriverInfo, optional |
| 199 | Driver metadata for CLIENT SETINFO. If provided, lib_name and lib_version |
| 200 | are ignored. If not provided, a DriverInfo will be created from lib_name |
| 201 | and lib_version. Explicit None disables CLIENT SETINFO. |
| 202 | lib_name : str, optional |
| 203 | **Deprecated.** Use driver_info instead. Library name for CLIENT SETINFO. |
| 204 | lib_version : str, optional |
| 205 | **Deprecated.** Use driver_info instead. Library version for CLIENT SETINFO. |
| 206 | """ |
| 207 | if (username or password) and credential_provider is not None: |
| 208 | raise DataError( |
| 209 | "'username' and 'password' cannot be passed along with 'credential_" |
| 210 | "provider'. Please provide only one of the following arguments: \n" |
| 211 | "1. 'password' and (optional) 'username'\n" |
| 212 | "2. 'credential_provider'" |
| 213 | ) |
| 214 | if event_dispatcher is None: |
| 215 | self._event_dispatcher = EventDispatcher() |
| 216 | else: |
| 217 | self._event_dispatcher = event_dispatcher |
| 218 | self.db = db |
| 219 | self.client_name = client_name |
| 220 | |
| 221 | # Handle driver_info: if provided, use it; otherwise create from lib_name/lib_version. |
| 222 | self.driver_info = resolve_driver_info(driver_info, lib_name, lib_version) |
nothing calls this directly
no test coverage detected