TorbatYar/backend/services/workspace/app/events/publisher.py
Mortezakoohjani a483b47369 feat(workspace): complete production workspace and content operations
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-12 11:54:17 +03:30

19 lines
600 B
Python

from app.models import OutboxEvent
class TransactionalEventPublisher:
def __init__(self, session):
self.session = session
async def publish(self, *, event_type, aggregate_type, aggregate_id, tenant_id, payload=None):
row = OutboxEvent(
tenant_id=tenant_id,
event_type=str(getattr(event_type, "value", event_type)),
aggregate_type=aggregate_type,
aggregate_id=str(aggregate_id),
payload=payload or {},
)
self.session.add(row)
await self.session.flush()
return row