How waydotnet/celery-pubsub works
Main Components
a) Publisher Component
• Represents the publishing interface
• Handles both synchronous (publish_now) and asynchronous (publish) operations
• Manages topic routing logic
b) Subscriber Component
• Manages subscription registration
• Handles topic pattern matching (*, #)
• Stores subscriber task references
c) Celery Integration Layer
• Shows integration with Celery's task system
• Represents task execution flow
d) Message Broker (External)
• Underlying message broker that Celery uses
• Typically RabbitMQ or Redis
→ : Data flow
⟷ : Integration point
🔷 : Core component
⬚ : External system
• ┌──────────────────────────────────────┐
• celery-pubsub Library │
┌──────────────┐ │ ┌──────────────┐ ┌──────────────┐ │
• Client │ │ │ Publisher │ │ Subscriber │ │
• Application │ ─publish/sub─────→│ │ Component │⟷│ Component │ │
• ┘ │ └──────────────┘ └──────────────┘ │
• ↓ ↑ │
• ┌──────────────────────────┐ │
• Celery Integration │ │
• ┴──────────────┬───────────┴────────┘
• ↓
• ┌────────────────────────────┐
• Message Broker │
• (RabbitMQ/Redis) │
• ┘
Key Elements to Highlight
a) Topic-based Routing:
• How topics are matched using wildcards (* and #)
• Topic routing flow from publishers to subscribers
b) Task Execution:
• Demonstrate how tasks are executed through Celery
• Both synchronous and asynchronous paths
c) Integration Points:
• Clear boundaries between the library and Celery
• External dependencies
Implementation Details
• Decorator-based subscription mechanism (@subscribe_to)
• Task registration system
• Demonstrate the topic pattern matching system
• Task execution flow
Additional Notes
• A note about version compatibility (Python 3.7+ and Celery 4/5)
• Distinction between sync and async operations
• Where task results can be optionally retrieved