4cd21b342b
Consolidates the reporter's poll cadence onto SqliteAuditWriterOptions instead of the hard-coded 30 s constant, closing deferred-work register item #21 (the config- shape cleanup its own XML doc flagged as a follow-up). - SqliteAuditWriterOptions.BacklogPollIntervalSeconds (default 30). - Reporter reads it via IOptions; precedence explicit-override (tests) > configured > 30 s default; a non-positive value falls back to the default. Corrected the stale "hard-code / tunable in a follow-up" class-doc. - Cadence tests + register updated (row 21 -> Resolved). Claude-Session: https://claude.ai/code/session_01MtdgwpEeCUn6cUA5f1LMPj
37 lines
1.7 KiB
C#
37 lines
1.7 KiB
C#
namespace ZB.MOM.WW.ScadaBridge.AuditLog.Site;
|
|
|
|
/// <summary>
|
|
/// Options for the site-side SQLite hot-path audit writer.
|
|
/// Mirrors the ZB.MOM.WW.ScadaBridge.SiteEventLogging pattern: a single SQLite connection
|
|
/// fed by a background writer task draining a bounded
|
|
/// <see cref="System.Threading.Channels.Channel{T}"/> so script-thread enqueues
|
|
/// never block on disk I/O.
|
|
/// </summary>
|
|
public sealed class SqliteAuditWriterOptions
|
|
{
|
|
/// <summary>SQLite database path (or in-memory URI for tests).</summary>
|
|
public string DatabasePath { get; set; } = "auditlog.db";
|
|
|
|
/// <summary>
|
|
/// Capacity of the bounded write queue. Set high enough that ordinary
|
|
/// script bursts never fill it; <see cref="System.Threading.Channels.BoundedChannelFullMode.Wait"/>
|
|
/// applies when the writer falls behind.
|
|
/// </summary>
|
|
public int ChannelCapacity { get; set; } = 4096;
|
|
|
|
/// <summary>Max number of pending events the writer drains in one transaction.</summary>
|
|
public int BatchSize { get; set; } = 256;
|
|
|
|
/// <summary>Soft flush interval the writer enforces when fewer than BatchSize events are queued.</summary>
|
|
public int FlushIntervalMs { get; set; } = 50;
|
|
|
|
/// <summary>
|
|
/// Poll cadence, in seconds, for the <c>SiteAuditBacklogReporter</c> hosted service
|
|
/// that probes the SQLite audit backlog and pushes the snapshot onto the site health
|
|
/// report. Half a typical 60 s health-report interval keeps the snapshot fresh without
|
|
/// spinning the SQL probe more often than necessary. A non-positive value falls back to
|
|
/// the reporter's 30 s default.
|
|
/// </summary>
|
|
public int BacklogPollIntervalSeconds { get; set; } = 30;
|
|
}
|