ifixkart-admin/Backend/app/events/publisher.py
Adithiyan bbd3a3e959 feat: initial commit — full platform snapshot
- Backend: FastAPI app with all models, services, schemas, routes
- Admin Panel: Next.js dashboard with all modules
  (CRM, POS, repairs, warranties, billing, notifications, etc.)
- Ecommerce: storefront (submodule) + product catalog
- AI Agents: .agents/ skill library for Antigravity IDE
- Docs: architecture, billing, notification gateway markdown
- Submodules: Backend/OpenWA, Ecommerce/File 2/storefront
2026-10-13 12:59:47 +05:30

25 lines
976 B
Python

"""
@event Event Publisher (Backend/app/events/publisher.py)
@purpose Event Bus publisher for broadcasting domain events across Commerce, Repair, and Core services.
"""
from typing import Dict, Any, List, Callable
import logging
logger = logging.getLogger("EventBus")
_SUBSCRIBERS: Dict[str, List[Callable[[Dict[str, Any]], None]]] = {}
def subscribe(event_type: str, handler: Callable[[Dict[str, Any]], None]):
if event_type not in _SUBSCRIBERS:
_SUBSCRIBERS[event_type] = []
_SUBSCRIBERS[event_type].append(handler)
logger.info(f"Subscribed handler for event: {event_type}")
def publish_event(event_type: str, payload: Dict[str, Any]):
logger.info(f"Publishing event [{event_type}] with payload keys: {list(payload.keys())}")
handlers = _SUBSCRIBERS.get(event_type, [])
for handler in handlers:
try:
handler(payload)
except Exception as e:
logger.error(f"Error handling event [{event_type}]: {e}")