feat: publish durable audit outbox events

This commit is contained in:
2026-07-29 14:16:28 +02:00
parent 1479946729
commit 0167ab752a
3 changed files with 11 additions and 2 deletions

View File

@@ -9,6 +9,7 @@ from govoplan_core.core.access import (
)
from govoplan_core.core.module_guards import drop_table_retirement_provider, persistent_table_uninstall_guard
from govoplan_core.core.modules import FrontendModule, MigrationSpec, ModuleContext, ModuleManifest
from govoplan_core.core.events import CAPABILITY_PLATFORM_EVENT_OUTBOX
from govoplan_core.core.views import ViewSurface
from govoplan_core.db.base import Base
@@ -34,6 +35,13 @@ def _audit_retention(context: ModuleContext):
return SqlAuditRetentionProvider()
def _event_outbox(context: ModuleContext):
del context
from govoplan_audit.backend.outbox import SqlAuditOutbox
return SqlAuditOutbox()
manifest = ModuleManifest(
id="audit",
name="Audit",
@@ -61,6 +69,7 @@ manifest = ModuleManifest(
capability_factories={
CAPABILITY_AUDIT_RECORDER: _audit_recorder,
CAPABILITY_AUDIT_RETENTION: _audit_retention,
CAPABILITY_PLATFORM_EVENT_OUTBOX: _event_outbox,
},
)

View File

@@ -36,7 +36,6 @@ class SqlAuditOutbox:
status="pending",
)
db.add(item)
db.flush()
return item
def dispatch_pending(
@@ -55,6 +54,7 @@ class SqlAuditOutbox:
or_(AuditOutboxEvent.next_attempt_at.is_(None), AuditOutboxEvent.next_attempt_at <= now),
)
.order_by(AuditOutboxEvent.created_at.asc(), AuditOutboxEvent.id.asc())
.with_for_update(skip_locked=True)
.limit(max(1, min(int(limit), 500)))
.all()
)