IAuditEventSink
Namespace: Meshmakers.Octo.Runtime.Contracts.AuditTrails
Single host-side extensibility point for audit events emitted by the engine. Every typed
audit-trail interface in the engine (e.g. ICkModelImportAuditTrail,
IArchiveAuditTrail) has a default forwarding implementation in
Runtime.Engine that translates its typed calls into AuditEvents and
calls IAuditEventSink.PublishAsync(AuditEvent, CancellationToken). A host project that wants events to land somewhere other
than registers exactly one
IAuditEventSink implementation — for example
EventRepositoryAuditEventSink in octo-common-services, which persists the
event to the platform event log.
public interface IAuditEventSink
Remarks:
Why the indirection: the typed audit-trail interfaces are resolved during the engine's DI
bootstrap (they are ctor-injected into IDatabaseCkModelRepository, which itself is
resolved during SystemContext construction). A per-interface bridge that ctor-injects
IEventRepository (and through it ISystemContext) would close a DI bootstrap
cycle and deadlock service startup — and did, in production, the day a per-interface bridge
was added (WI #3324). Routing every audit-trail interface through a single
IAuditEventSink means a host can break the cycle exactly once, in the sink
implementation, by lazy-resolving the event repository via IServiceProvider.
Methods
PublishAsync(AuditEvent, CancellationToken)
Publishes an audit event. Implementations must not throw on transient failures (the engine operations that triggered the event must still succeed even if audit-trail bookkeeping fails); recoverable errors are logged inside the sink and swallowed.
Task PublishAsync(AuditEvent auditEvent, CancellationToken cancellationToken)
Parameters
auditEvent AuditEvent
cancellationToken CancellationToken