first claude draft
This commit is contained in:
34
shared/events/__init__.py
Normal file
34
shared/events/__init__.py
Normal file
@@ -0,0 +1,34 @@
|
||||
"""
|
||||
Event publishing/subscribing abstraction layer.
|
||||
|
||||
Supports:
|
||||
- Redis Pub/Sub (default, simple)
|
||||
- Redis Streams (with consumer groups, persistence)
|
||||
- Kafka (future, for high-throughput)
|
||||
|
||||
Usage:
|
||||
from shared.events import get_publisher, get_subscriber
|
||||
|
||||
# Publishing
|
||||
async with get_publisher() as pub:
|
||||
await pub.publish("metrics.raw", {"machine_id": "m1", ...})
|
||||
|
||||
# Subscribing
|
||||
async with get_subscriber(["metrics.raw", "alerts.*"]) as sub:
|
||||
async for topic, message in sub.consume():
|
||||
process(topic, message)
|
||||
"""
|
||||
|
||||
from .base import EventPublisher, EventSubscriber, Event
|
||||
from .redis_pubsub import RedisPubSubPublisher, RedisPubSubSubscriber
|
||||
from .factory import get_publisher, get_subscriber
|
||||
|
||||
__all__ = [
|
||||
"EventPublisher",
|
||||
"EventSubscriber",
|
||||
"Event",
|
||||
"RedisPubSubPublisher",
|
||||
"RedisPubSubSubscriber",
|
||||
"get_publisher",
|
||||
"get_subscriber",
|
||||
]
|
||||
Reference in New Issue
Block a user