6bf9dfb3c5
Claude-Session: https://claude.ai/code/session_01MtdgwpEeCUn6cUA5f1LMPj
49 lines
2.7 KiB
C#
49 lines
2.7 KiB
C#
using ZB.MOM.WW.Configuration;
|
|
|
|
namespace ZB.MOM.WW.ScadaBridge.SiteCallAudit;
|
|
|
|
/// <summary>
|
|
/// Validates <see cref="SiteCallAuditOptions"/> at startup. The durations feed
|
|
/// stuck-call detection, KPI windowing, the central→site relay Ask timeout, and
|
|
/// the two central-singleton scheduler cadences (reconciliation + purge); a
|
|
/// zero/negative value makes an Akka scheduler spin or a KPI window collapse.
|
|
/// Registered with <c>ValidateOnStart()</c> so a bad <c>ScadaBridge:SiteCallAudit</c>
|
|
/// section fails fast at boot with a clear, key-naming message. Validates the
|
|
/// BASE properties — the <c>Resolved*</c> computed properties clamp bad cadence
|
|
/// values away and would hide the misconfiguration.
|
|
/// </summary>
|
|
public sealed class SiteCallAuditOptionsValidator : OptionsValidatorBase<SiteCallAuditOptions>
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Validate(ValidationBuilder builder, SiteCallAuditOptions options)
|
|
{
|
|
builder.RequireThat(options.StuckAgeThreshold > TimeSpan.Zero,
|
|
$"ScadaBridge:SiteCallAudit:StuckAgeThreshold must be a positive duration " +
|
|
$"(was {options.StuckAgeThreshold}); it is the age past which a cached call is flagged stuck.");
|
|
|
|
builder.RequireThat(options.KpiInterval > TimeSpan.Zero,
|
|
$"ScadaBridge:SiteCallAudit:KpiInterval must be a positive duration " +
|
|
$"(was {options.KpiInterval}); it is the trailing window for the throughput KPIs.");
|
|
|
|
builder.RequireThat(options.RelayTimeout > TimeSpan.Zero,
|
|
$"ScadaBridge:SiteCallAudit:RelayTimeout must be a positive duration " +
|
|
$"(was {options.RelayTimeout}); it is the Ask timeout for the central→site Retry/Discard relay.");
|
|
|
|
builder.RequireThat(options.ReconciliationInterval > TimeSpan.Zero,
|
|
$"ScadaBridge:SiteCallAudit:ReconciliationInterval must be a positive duration " +
|
|
$"(was {options.ReconciliationInterval}); it is the period of the per-site reconciliation pull.");
|
|
|
|
builder.RequireThat(options.ReconciliationBatchSize > 0,
|
|
$"ScadaBridge:SiteCallAudit:ReconciliationBatchSize must be positive " +
|
|
$"(was {options.ReconciliationBatchSize}); it is the max rows requested per PullSiteCalls RPC.");
|
|
|
|
builder.RequireThat(options.PurgeInterval > TimeSpan.Zero,
|
|
$"ScadaBridge:SiteCallAudit:PurgeInterval must be a positive duration " +
|
|
$"(was {options.PurgeInterval}); it is the period of the daily terminal-row purge tick.");
|
|
|
|
builder.RequireThat(options.RetentionDays > 0,
|
|
$"ScadaBridge:SiteCallAudit:RetentionDays must be positive " +
|
|
$"(was {options.RetentionDays}); it is the retention window for terminal SiteCalls rows.");
|
|
}
|
|
}
|