fix: map ssl=True to connection_class=SSLConnection so TLS works via pool_kwargs (redis-4)

Signed-off-by: disqualifier <dev@disqualifier.me>
This commit is contained in:
2026-07-02 17:22:30 -04:00
parent a0e9fc28d6
commit 4688dd4181
3 changed files with 21 additions and 4 deletions
+8 -3
View File
@@ -14,19 +14,19 @@ datastore trio (`redis` / `psql` / `mysql`), a sibling of the `mongo` lib.
`requirements.txt`: `requirements.txt`:
``` ```
redis_store @ git+ssh://git@git.rethinkstudios.io/rethink-public/redis.git@v0.1.2 redis_store @ git+ssh://git@git.rethinkstudios.io/rethink-public/redis.git@v0.1.3
``` ```
Direct: Direct:
```bash ```bash
pip install "redis_store @ git+ssh://git@git.rethinkstudios.io/rethink-public/redis.git@v0.1.2" pip install "redis_store @ git+ssh://git@git.rethinkstudios.io/rethink-public/redis.git@v0.1.3"
``` ```
Pulls `redis>=5` (redis-py, which ships the asyncio client — **not** the dead standalone Pulls `redis>=5` (redis-py, which ships the asyncio client — **not** the dead standalone
`aioredis`). `aioredis`).
Drop the `@v0.1.2` suffix from the line above to install the latest unpinned. Drop the `@v0.1.3` suffix from the line above to install the latest unpinned.
## Usage ## Usage
@@ -66,6 +66,11 @@ Pool sizing/timeout are `max_connections=` and `pool_timeout=` (how long a calle
a free connection when the pool is saturated). Pass the driver's own `timeout=` in a free connection when the pool is saturated). Pass the driver's own `timeout=` in
`pool_kwargs` and construction raises a clear `ValueError` — use `pool_timeout=`. `pool_kwargs` and construction raises a clear `ValueError` — use `pool_timeout=`.
`ssl=True` maps to `connection_class=redis.asyncio.SSLConnection`, so TLS works via the
documented `pool_kwargs` path (the default connection class has no `ssl` parameter and
would otherwise defer a `TypeError` to `connect()`). Pass ssl-prefixed kwargs alongside
it (`ssl_ca_certs`, `ssl_certfile`, ...) to configure the handshake.
## Error contract — fail loud ## Error contract — fail loud
Unlike the `mongo` lib (which log-and-swallows, returning a safe default), **this lib Unlike the `mongo` lib (which log-and-swallows, returning a safe default), **this lib
+1 -1
View File
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project] [project]
name = "redis_store" name = "redis_store"
version = "0.1.2" version = "0.1.3"
description = "async redis wrapper over redis-py asyncio with a raw escape hatch, fail-loud and config-free" description = "async redis wrapper over redis-py asyncio with a raw escape hatch, fail-loud and config-free"
requires-python = ">=3.10" requires-python = ">=3.10"
dependencies = [ dependencies = [
+12
View File
@@ -34,6 +34,9 @@ notes:
- import is `redis_store`; the repo/distribution is `redis` (the driver owns the - import is `redis_store`; the repo/distribution is `redis` (the driver owns the
`redis` import name, so the package can't also be `redis`) `redis` import name, so the package can't also be `redis`)
- pub/sub and pipeline helpers are intentionally not wrapped yet — use `.client` - pub/sub and pipeline helpers are intentionally not wrapped yet — use `.client`
- ssl=True maps to connection_class=redis.asyncio.SSLConnection so TLS actually
works via the documented pool_kwargs path; pass ssl-prefixed kwargs alongside it
(ssl_ca_certs, ssl_certfile, ...) to configure the handshake
""" """
import logging import logging
@@ -75,12 +78,21 @@ class RedisDB:
`timeout` is the pool's own kwarg (set from pool_timeout here), so passing it in `timeout` is the pool's own kwarg (set from pool_timeout here), so passing it in
pool_kwargs would collide — reject it with a clear pointer rather than let the pool_kwargs would collide — reject it with a clear pointer rather than let the
driver raise a cryptic "multiple values for 'timeout'". driver raise a cryptic "multiple values for 'timeout'".
`ssl=True` is mapped to `connection_class=redis.asyncio.SSLConnection` — the
default async Connection class has no `ssl` parameter, so passing it straight
through pool_kwargs would defer the failure to connect() as a raw TypeError.
pass ssl-prefixed kwargs (ssl_ca_certs, ssl_certfile, ...) alongside ssl=True to
configure the TLS connection; an explicit connection_class in pool_kwargs is
left untouched.
""" """
if "timeout" in pool_kwargs: if "timeout" in pool_kwargs:
raise ValueError( raise ValueError(
"redis_store: pass the pool wait timeout as pool_timeout=, not timeout= " "redis_store: pass the pool wait timeout as pool_timeout=, not timeout= "
"(timeout is filled from pool_timeout)" "(timeout is filled from pool_timeout)"
) )
if pool_kwargs.pop("ssl", False):
pool_kwargs.setdefault("connection_class", redis.SSLConnection)
self._pool = redis.BlockingConnectionPool( self._pool = redis.BlockingConnectionPool(
host=host, host=host,
port=port, port=port,