feat(commons): add IAuditWriter and ICentralAuditWriter (#23)

This commit is contained in:
Joseph Doherty
2026-05-20 09:56:49 -04:00
parent e41a18ba7d
commit 8ac5ebe97e
3 changed files with 69 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
using ScadaLink.Commons.Entities.Audit;
namespace ScadaLink.Commons.Interfaces.Services;
/// <summary>
/// Boundary-side abstraction for emitting Audit Log (#23) events.
/// Implementations on the site write to local SQLite hot-path; on central they write to MS SQL directly.
/// Failures must NEVER abort the user-facing action.
/// </summary>
public interface IAuditWriter
{
/// <summary>
/// Persist an audit event. Best-effort: implementations must swallow/log internal failures
/// rather than propagating them to the calling boundary code.
/// </summary>
Task WriteAsync(AuditEvent evt, CancellationToken ct = default);
}

View File

@@ -0,0 +1,16 @@
using ScadaLink.Commons.Entities.Audit;
namespace ScadaLink.Commons.Interfaces.Services;
/// <summary>
/// Central-only audit writer for the direct-write path (Notification Outbox dispatch, Inbound API).
/// Distinct from <see cref="IAuditWriter"/> so DI binding can differ between site and central hosts.
/// </summary>
public interface ICentralAuditWriter
{
/// <summary>
/// Persist an audit event into the central AuditLog table directly (bypassing site telemetry).
/// Best-effort: implementations must swallow/log internal failures rather than propagating them.
/// </summary>
Task WriteAsync(AuditEvent evt, CancellationToken ct = default);
}