merge: chore/cleanup-remove-bloat-and-secrets into main
This commit is contained in:
commit
bde2f3a97d
1173 changed files with 437609 additions and 0 deletions
27
app/domain/alerts/broadcaster.py
Normal file
27
app/domain/alerts/broadcaster.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
"""Broadcaster — pushes fired alert events to WebSocket subscribers.
|
||||
|
||||
Uses core/websocket's broadcast helper. No FastAPI imports.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from app.core.logging import get_logger
|
||||
from app.core.websocket import broadcast_alert
|
||||
from app.domain.alerts.models import AlertEvent
|
||||
|
||||
log = get_logger(__name__)
|
||||
|
||||
|
||||
class AlertBroadcaster:
|
||||
"""Thin wrapper that knows how to push an AlertEvent to live clients."""
|
||||
|
||||
async def broadcast_event(self, event: AlertEvent) -> None:
|
||||
"""Broadcast a single event to all connected WebSocket subscribers."""
|
||||
try:
|
||||
await broadcast_alert(event.model_dump(mode="json"))
|
||||
except Exception as e:
|
||||
# Broadcasting failure must not break the firing path.
|
||||
log.warning(
|
||||
"alert_broadcast_failed",
|
||||
error=str(e),
|
||||
alert_id=event.subscription_id,
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue