All cross-service events now flow through ap_activities with a unified EventProcessor. Internal events use visibility="internal"; federation activities use visibility="public" and get delivered by a wildcard handler. - Add processing columns to APActivity (process_state, actor_uri, etc.) - New emit_activity() / register_activity_handler() API - EventProcessor polls ap_activities instead of domain_events - Rewrite all handlers to accept APActivity - Migrate all 7 emit_event call sites to emit_activity - publish_activity() sets process_state=pending directly (no emit_event bridge) - Migration to drop domain_events table Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
23 lines
699 B
Python
23 lines
699 B
Python
from __future__ import annotations
|
|
|
|
import logging
|
|
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
from shared.events import register_activity_handler
|
|
from shared.models.federation import APActivity
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
async def on_order_created(activity: APActivity, session: AsyncSession) -> None:
|
|
log.info("order.created: order_id=%s", activity.object_data.get("order_id"))
|
|
|
|
|
|
async def on_order_paid(activity: APActivity, session: AsyncSession) -> None:
|
|
log.info("order.paid: order_id=%s", activity.object_data.get("order_id"))
|
|
|
|
|
|
register_activity_handler("Create", on_order_created, object_type="rose:Order")
|
|
register_activity_handler("rose:OrderPaid", on_order_paid)
|