Phase 5: Outbox DLQ, Monitoring, Consumer-Registry

- Migration 0092: DLQ columns (error_message, failed_at) + consumer_inbox RLS fix
- outbox.py: DLQ logic, replay functions, stats, consumer registry
- app/routes/outbox.py: 5 API endpoints (stats, failed, replay, replay-all, consumer-registry)
- outbox_deliveries tracking per consumer handler
- 18/18 tests passing
This commit is contained in:
Agent Zero
2026-08-02 23:25:54 +02:00
parent 24cb10a7a2
commit 07a99975ec
12 changed files with 1017 additions and 79 deletions
+5 -5
View File
@@ -67,7 +67,7 @@ async def test_process_outbox_batch_publishes_events(
# Use a separate session to simulate the worker
async with session_factory() as worker_session:
count = await process_outbox_batch(worker_session, batch_size=10)
count = await process_outbox_batch(worker_session, batch_size=10, tenant_ids=[tenant_id])
assert count == 1
assert len(received_events) == 1
@@ -116,7 +116,7 @@ async def test_process_outbox_batch_retry_on_failure(
await db_session.commit()
async with session_factory() as worker_session:
count = await process_outbox_batch(worker_session, batch_size=10)
count = await process_outbox_batch(worker_session, batch_size=10, tenant_ids=[tenant_id])
assert count == 0 # nothing was successfully published
@@ -162,7 +162,7 @@ async def test_process_outbox_batch_max_attempts_marks_failed(
await db_session.commit()
async with session_factory() as worker_session:
count = await process_outbox_batch(worker_session, batch_size=10)
count = await process_outbox_batch(worker_session, batch_size=10, tenant_ids=[tenant_id])
assert count == 0
@@ -200,14 +200,14 @@ async def test_enqueue_multiple_events_and_batch_size(
await db_session.commit()
async with session_factory() as worker_session:
count = await process_outbox_batch(worker_session, batch_size=3)
count = await process_outbox_batch(worker_session, batch_size=3, tenant_ids=[tenant_id])
assert count == 3
assert len(received) == 3
# Process the remaining 2
async with session_factory() as worker_session:
count2 = await process_outbox_batch(worker_session, batch_size=3)
count2 = await process_outbox_batch(worker_session, batch_size=3, tenant_ids=[tenant_id])
assert count2 == 2
assert len(received) == 5
finally: