Skip to content

feat: add high-level Redis Pub/Sub API for real-time applications#27

Open
massooti wants to merge 15 commits into
redis:mainfrom
massooti:main
Open

feat: add high-level Redis Pub/Sub API for real-time applications#27
massooti wants to merge 15 commits into
redis:mainfrom
massooti:main

Conversation

@massooti

@massooti massooti commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

This is belonging to this issue #24:

Without this feature, developers must manually:

  • Create and close Redis Pub/Sub connections.
  • Handle subscription cleanup when WebSockets disconnect.
  • Coordinate concurrent WebSocket reads and Redis messages.
  • Reimplement channel prefixes, serialization, cluster handling, and test overrides.
  • Avoid an in-memory connection manager that only works inside one process.

With the helper:

Worker A ─┐
Worker B ─┼── Redis channel: room:42 ── broadcast to every connected client
Worker C ─┘

This adds a new project capability: the SDK moves from HTTP caching and raw Redis injection into reusable real-time FastAPI infrastructure. It directly supports chat
rooms, live notifications, job-progress updates, dashboards, and cross-worker broadcasts while reusing the existing Redis pool.

@codecov-commenter

codecov-commenter commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.96970% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 98.23%. Comparing base (d98446c) to head (19c7baa).

Files with missing lines Patch % Lines
src/redis_fastapi/deps.py 87.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #27      +/-   ##
==========================================
- Coverage   98.29%   98.23%   -0.06%     
==========================================
  Files           9       10       +1     
  Lines         764      795      +31     
==========================================
+ Hits          751      781      +30     
- Misses         13       14       +1     
Flag Coverage Δ
unittests 98.23% <96.96%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tishun tishun added enhancement New feature or request needs-triage The team needs to go through the provided information and analyse it labels Jul 23, 2026
emiliano-go added a commit to emiliano-go/fastapi-redis-sdk that referenced this pull request Jul 23, 2026
get_async_redis now takes starlette.requests.HTTPConnection instead
of fastapi.Request, so it works in both HTTP endpoints and WebSocket
handlers. PubSubManagerDep and PubSubManager can now be injected
directly in WebSocket endpoints without manually calling
_get_pool_state.

This approach was inspired by PR redis#27 (massooti).
@massooti
massooti marked this pull request as ready for review July 25, 2026 06:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request needs-triage The team needs to go through the provided information and analyse it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants