Files
sysmonstm/shared/events/__init__.py
2025-12-29 14:40:06 -03:00

35 lines
909 B
Python

"""
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",
]