39 lines
1.8 KiB
C#
39 lines
1.8 KiB
C#
using ZB.MOM.WW.Configuration;
|
|
|
|
namespace ZB.MOM.WW.ScadaBridge.AuditLog.Site;
|
|
|
|
/// <summary>
|
|
/// Validates <see cref="SqliteAuditWriterOptions"/> at host startup
|
|
/// (arch-review 08 round 2 NF4). The channel/batch/flush knobs feed the
|
|
/// background writer task; a zero anywhere stalls it (nothing drains, nothing
|
|
/// flushes), and an empty <c>DatabasePath</c> leaves the SQLite writer with no
|
|
/// backing store. <see cref="SqliteAuditWriterOptions.BacklogPollIntervalSeconds"/>
|
|
/// is intentionally NOT validated — a non-positive value has a documented
|
|
/// fall-back-to-30s contract in <c>SiteAuditBacklogReporter</c>.
|
|
/// </summary>
|
|
public sealed class SqliteAuditWriterOptionsValidator : OptionsValidatorBase<SqliteAuditWriterOptions>
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Validate(ValidationBuilder builder, SqliteAuditWriterOptions options)
|
|
{
|
|
builder.RequireThat(!string.IsNullOrWhiteSpace(options.DatabasePath),
|
|
$"AuditLog:SiteWriter:{nameof(SqliteAuditWriterOptions.DatabasePath)} must be a non-empty path.");
|
|
|
|
builder.RequireThat(options.ChannelCapacity > 0,
|
|
$"AuditLog:SiteWriter:{nameof(SqliteAuditWriterOptions.ChannelCapacity)} " +
|
|
$"({options.ChannelCapacity}) must be > 0.");
|
|
|
|
builder.RequireThat(options.BatchSize > 0,
|
|
$"AuditLog:SiteWriter:{nameof(SqliteAuditWriterOptions.BatchSize)} " +
|
|
$"({options.BatchSize}) must be > 0.");
|
|
|
|
builder.RequireThat(options.FlushIntervalMs > 0,
|
|
$"AuditLog:SiteWriter:{nameof(SqliteAuditWriterOptions.FlushIntervalMs)} " +
|
|
$"({options.FlushIntervalMs}) must be > 0.");
|
|
|
|
// BacklogPollIntervalSeconds is deliberately unchecked: a non-positive
|
|
// value falls back to the reporter's 30s default (see the option's
|
|
// remarks + register row 21 resolution).
|
|
}
|
|
}
|